diff --git a/Problem 5/my_acceleration.m b/Problem 5/my_acceleration.m index 32a8c6d..d420c08 100644 --- a/Problem 5/my_acceleration.m +++ b/Problem 5/my_acceleration.m @@ -10,7 +10,7 @@ function [ax,ay,az]=my_acceleration(x,y,z,t) % ax = acceleration in x-direction % ay = acceleration in y-direction % az = acceleration in z-direction - + function v=diff_match_dims(x,t) v=zeros(length(t),1); v(1:end-1)=diff(x)./diff(t); @@ -19,8 +19,8 @@ function [ax,ay,az]=my_acceleration(x,y,z,t) [vx,vy,vz]=my_velocity(x,y,z,t); - ax = diff_match_dims(vx,t); - ay = diff_match_dims(vy,t); - az = diff_match_dims(vz,t); + ax = diff_match_dims(vx',t); + ay = diff_match_dims(vy',t); + az = diff_match_dims(vz',t); -end \ No newline at end of file +end diff --git a/README.md b/README.md index c0985ef..a4514ea 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -<<<<<<< HEAD # 01_ME3255_repo # Answer to Homework Question @@ -55,56 +54,3 @@ 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