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
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 (24 sloc)
1.12 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
% Part A | |
% Plots data from the US Energy csv file | |
set(0,'defaultAxesFontSize',16) | |
set(0,'defaultTextFontSize',16) | |
set(0,'defaultLineLineWidth',3) | |
data=dlmread('energy.csv',',',2,0); | |
h=figure(1) | |
plot(data(:,1),data(:,3),data(:,1),data(:,9)) %plots data from certain columns of the file | |
xlabel('Year') %creates x axis label | |
ylabel('Energy Used (BTU x 1 Trillion)') %creates y axis label | |
legend('Residential','Transportation','Location','Northwest') %creates legend and moves it to top right corner of graph | |
title('US Energy Consumption by Sector vs Time') %creates title | |
saveas(h,'figure_02.png') | |
print(h,'figure_02.png') | |
% Part B | |
% Plots cumulative data from the US Energy csv file | |
A = figure(); | |
plot(data(:,1),data(:,3),data(:,1),data(:,9)) %plots data from certain columns of the same file | |
xlabel('Year') %creates x axis label | |
ylabel('Cumulative Energy Used (BTU * 1e6 Trillion)') %creates y axis label | |
legend('Residential','Transportation','Location','Northwest') %creates legend and moves it to top right corner of graph | |
title('Cumulative US Energy Consumption by Sector vs Time') %creates title | |
saveas(A,'figure_01') | |
print('figure_01'); |