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
% 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');