Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Braisted committed Sep 14, 2017
2 parents 54f5243 + 91d61e3 commit e30a92d
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
54 changes: 54 additions & 0 deletions README.md
@@ -1,3 +1,4 @@
<<<<<<< HEAD
# 01_ME3255_repo

# Answer to Homework Question
Expand Down Expand Up @@ -54,3 +55,56 @@ saveas(h,'figure_02.png')
```

#Problem 5 (Velocity and Acceleration)
=======
# 01_ME3255_repo

# Answer to Homework Question
I hope to learn how to perform MATLAB functions more easily.

#Problem 3
```MATLAB
A_66=zeros(6:6);
for i=1:6;
j=1:6;
A_66(i,j)=i*j;
end
fprintf('mean of A_66 = %1.2f\nstdev of A_66 = %1.2f\n',mean(A_66(:)),std(A_66(:)))
```
Outputs:

mean of A_66 = 12.25

stdev of A_66 = 9.07

#Problem 4
```MATLAB
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')
```
#Problem 5 (Velocity and Acceleration)
>>>>>>> 91d61e3e4b17400ee1c842feddcb5f3ad25e1994
27 changes: 27 additions & 0 deletions US_energy_by_sector_code.m
@@ -1,3 +1,4 @@
<<<<<<< HEAD
data=dlmread('US_energy_by_sector.csv',',',2,0);
figure(1)
plot(data(:,1),data(:,3),data(:,1),data(:,9));
Expand All @@ -22,3 +23,29 @@ xlabel('Time (years)')
ylabel('Total Energy Consumed (quintillions of BTUs)')
legend('Residential','Transportation','Location','northwest')
title('Cumulative US Energy Consumption from 1949 to 2016')
=======
data=dlmread('US_energy_by_sector.csv',',',2,0);
figure(1)
plot(data(:,1),data(:,3),data(:,1),data(:,9));
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')


rescum=cumsum(data(:,3))./1000000;%cumulative sum of residential energy
%consumption in quintillions
transcum=cumsum(data(:,9))./1000000;%cumulative sum of transportational
%energy consumption in quintillions
figure(2)
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')
>>>>>>> 91d61e3e4b17400ee1c842feddcb5f3ad25e1994

0 comments on commit e30a92d

Please sign in to comment.