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/Problem 4/US_energy_by_sector_code.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
27 lines (26 sloc)
1.11 KB
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
data=dlmread('US_energy_by_sector.csv',',',2,0); | |
h=figure(); | |
plot(data(:,1),data(:,3),data(:,1),data(:,9)); | |
%plotting residential energy consumption and transportational energy | |
%consumption from 1949 to 2016 in trillions of BTUs | |
set(0, 'defaultAxesFontSize', 16) | |
set(0,'defaultTextFontSize',14) | |
set(0,'defaultLineLineWidth',3) | |
set(gcf, 'Position', [200, 200, 1000, 800]) | |
xlabel('Time (years)') | |
ylabel('Total Energy Consumed (trillions of BTUs)') | |
legend('Residential','Transportation','Location','northwest') | |
title('US Energy Consumption from 1949 to 2016') | |
saveas(h,'figure_01.png') | |
rescum=cumsum(data(:,3))./1000000;%cumulative sum of residential energy | |
%consumption in quintillions of BTUs | |
transcum=cumsum(data(:,9))./1000000;%cumulative sum of transportational | |
%energy consumption in quintillions of BTUs | |
h=figure(); | |
plot(data(:,1),rescum,data(:,1),transcum) | |
set(gcf, 'Position', [500, 200, 1000, 800]) | |
xlabel('Time (years)') | |
ylabel('Total Energy Consumed (quintillions of BTUs)') | |
legend('Residential','Transportation','Location','northwest') | |
title('Cumulative US Energy Consumption from 1949 to 2016') | |
saveas(h,'figure_02.png') |