%emissions_plot
%PC MA 302

fid = fopen('emissions.txt','r');

if(fid ==-1)
    error('File open not successful')
else
    disp('File open successful')
end

mat = fscanf(fid,'%d %f %f',[3 inf]);
size(mat)
vec= mat';

plot(vec(:,1),vec(:,2),'r-','LineWidth',2);
xlabel('Year');
ylabel('C0_2 concentation in ppm');
title('Global C0_2 concetration');
axis tight

annual_av = vec(:,2);
years = vec(:,1);
diff = (annual_av(2:end)-annual_av(1:end-1))./(annual_av(1:end-1));

figure

plot(years(2:end),100*diff,'k-','LineWidth',2);
ylim([0 1]);
xlabel('year');
ylabel('% increase in average');
title('Annual percentage increase');




closeresult = fclose(fid);

if closeresult == 0
    disp('File close successful');
else
    error('File close not successful');
end
