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 6
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 (25 sloc)
940 Bytes
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
%Creates functions that calculate velocity and acceleration over time | |
function[vx,vy,vz] = velocity(x,y,z,t) | |
%function of 3D velocity over time | |
vx = zeroes(length(t),1); %x-direction velocity | |
vy = zeroes(length(t),1); %y-direction velocity | |
vz = zeroes(length(t),1); %z-direction velocity | |
vx(1:end-1) = diff(x)./diff(t); %finds vx using the derivitive of position x | |
vy(1:end-1) = diff(y)./diff(t); %finds vy using the derivitive of position y | |
vz(1:end-1) = diff(z)./diff(t); %finds vz using the derivitive of position z | |
vx(end) = vx(end-1); | |
vy(end) = vy(end-1); | |
vz(end) = vz(end-1); | |
end | |
function[ax,ay,az] = acceleration(x,y,z,t) | |
%function of 3D acceleration over time | |
function v=diff_match_dims(x,t) | |
v = zeroes(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); | |
end |