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개)
Star Strider
2018년 10월 4일
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
Drishya Dinesh
2020년 12월 2일
편집: Drishya Dinesh
2020년 12월 2일
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!