Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
set(0, 'defaultAxesFontsize', 16)
set(0, 'defaultTextFontSize', 16)
set(0, 'defaultLineLineWidth', 3)
data=dlmread('US_energy_by_sector.csv',',',2,0)
plot(data(:,1),data(:,3),data(:,1),data(:,9))
% residential use in column 3
% transportation use in column 9
title('US energy consumption by year')
xlabel('year')
ylabel('energy use (trillions of btus)')
legend('residential','transportation','location','NorthWest')
print('figure_01.png')
cum_residential= cumsum(data(:,3))/10^6;
% calculate cumulative sum of residential use in units of quintillions
cum_transportation = cumsum(data(:,9))/10^6;
% calculate cumulative sum of transportation use in units of quintillions
figure; plot(data(:,1),cum_residential,data(:,1),cum_transportation)
title('US energy consumption by year')
xlabel('year')
ylabel('cumulative energy use (quintillions of btus)')
legend('residential','transportation','location','NorthWest')
print ('figure_02.png')