How to plot trajectory
Afficher commentaires plus anciens
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
Réponses (1)
Star Strider
le 4 Oct 2018
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 commentaire
Drishya Dinesh
le 2 Déc 2020
Modifié(e) : Drishya Dinesh
le 2 Déc 2020
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
Catégories
En savoir plus sur Networks dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!