% coalprod.m
% Sample Solution: CS 221 HW3

% Import data from CSV file
Data = csvread('coalprod.csv');

% Extract columns into variables
Years = Data(:,1)';
Eastern = Data(:,2)';
Western = Data(:,3)';

% Separate variable for trending
TrendYears = 2002:0.05:2014;

% These lines are provided to copy and paste
EP = polyfit(Years, Eastern, 1);
WP = polyfit(Years, Western, 1);
ETrend = polyval(EP, TrendYears);
WTrend = polyval(WP, TrendYears);

% Plot the data:
% Note: This is sort of rudimentary. 
% Hopefully students can do better than this.

plot(Years, Eastern, Years, Western, TrendYears, ETrend, TrendYears, WTrend);
title('Coal Production in Eastern and Western Kentucky Fields');
xlabel('Year');
ylabel('Output (Thousand Short Tons)');

% Save and upload JPEG and this script.
