% 
% Name: Solution McGee
% Description:  The solution.
%

clear
close all

% Read the data in .xlsx files
pdata = xlsread('production.xlsx');
cdata = xlsread('consumption.xlsx');

% For simplicity, treat the "not available" data as 0
pdata(isnan(pdata)) = 0;
cdata(isnan(cdata)) = 0;

% -------------BEGIN YOUR CODE BELOW---------------

hold on  % Allow next graph to be drawn on top of current graph
plot(pdata(:, 1), pdata(:, [2:4, 12]), "--")  % Selects certain rows
plot(cdata(:, 1), cdata(:, [2:4, 12]))        % and columns of matrices
hold off
xlabel("Year")
ylabel("Quadrillion BTUs")
legend("p-coal", "p-gas", "p-oil", "p-ren", ...
    "c-coal", "c-gas", "c-oil", "c-ren", ...
    'Location', 'northwest')
title("Energy Consumption vs. Production")

figure(2)  % Starts next graph in new window

plot(pdata(:, 1), (pdata(:, 13) ./ cdata(:, 13)))
title("Production / Consumption")
xlabel("Year")
ylabel("Ratio")