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
%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