Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
readme
  • Loading branch information
Braisted committed Sep 14, 2017
1 parent b93219f commit 708dca7
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions README.md
Expand Up @@ -79,3 +79,64 @@ saveas(g,'figure01.png')
![Velocity Comparison by Varying Time Steps](./Problem 3/figure01.png)

#Problem 6 (Velocity and Acceleration)

#3D Velocity
```MATLAB
function [vx,vy,vz] = my_velocity(x,y,z,t)
% Help documentation of "my_velocity"
% This function computes the velocity in the x- and y-directions given
% three vectors of position in x- and y-directions as a function of time
% x = x-position
% y = y-position
% z = z-position
% t = time
% output
% vx = velocity in x-direction
% vy = velocity in y-direction
% vz = velocity in z-direction
vx=zeros(length(t),1);
vy=zeros(length(t),1);
vz=zeros(length(t),1);
vx(1:end-1) = diff(x)./diff(t); % calculate vx as delta x/delta t
vy(1:end-1) = diff(y)./diff(t); % calculate vy as delta y/delta t
vz(1:end-1) = diff(z)./diff(t); % calculate vy as delta y/delta t
vx(end) = vx(end-1);
vy(end) = vy(end-1);
vz(end) = vz(end-1);
end
```

#3D Acceleration
```MATLAB
function [ax,ay,az]=my_acceleration(x,y,z,t)
% Help documentation of "my_acceleration"
% This function computes the acceleration in the x- and y-directions given
% three vectors of position in x- and y-directions as a function of time
% x = x-position
% y = y-position
% z = z-position
% t = time
% output
% 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);
v(end)=v(end-1);
end
[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);
%added apostrophe for derivatives of velocity
end
```

0 comments on commit 708dca7

Please sign in to comment.