Permalink
Cannot retrieve contributors at this time
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?
01_ME3255_repo/US_energy_by_sector.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
29 lines (22 sloc)
941 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | |