How to plot trajectory

We were asked to plot the trajectory of a diver off a diving board, and I am having trouble getting my graph to publish for this problem. Can anyone tell me what I have done wrong? Thank you.
if true
t=2.5; %in seconds
Vox=2
Voy=8.25
tx=0:.1:2.5; %this will give me an array for the time of the diver in the x position
ty=0:.1:2.5; %this will give the array for the time of the diver in the y-position
function [tx,ty]= trajectory(Vox,Voy,tx,g)%function for varying angle
x=Vox*cos(0)*tx; %gives the position of the x
y=Voy*(sin(0)*ty)-(.5*g*(ty.^2)); %gives the position of the y
plot (x,y)
end
end

回答(1 个)

Your ‘trajectory’ function wants ‘ty’ as well, so you need to include that in the argument list. Other than that, you need to call it correctly.
Try this:
g = 9.81;
t=2.5; %in seconds
Vox=2;
Voy=8.25;
tx=0:.1:2.5; %this will give me an array for the time of the diver in the x position
ty=0:.1:2.5; %this will give the array for the time of the diver in the y-position
function [tx,ty]= trajectory(Vox,Voy,tx,ty,g)%function for varying angle
x=Vox*cos(0)*tx; %gives the position of the x
y=Voy*(sin(0)*ty)-(.5*g*(ty.^2)); %gives the position of the y
plot (x,y)
end
[tx,ty] = trajectory(Vox,Voy,tx,ty,g);
When I run it, it produces an acceptable plot.
Also, if you want ‘trajectory’ to return the calculated values for ‘x’ and ‘y’, you need to tell it.
Consider:
function [x,y] = trajectory(Vox,Voy,tx,ty,g)%function for varying angle

1 个评论

can i get a time varying trajectory for an aerial vehicle in 3d (6 dof motion- x,y,z,phi,theta,psi)? Even helical is fine

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Networks 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by