How to plot trajectory

조회 수: 3 (최근 30일)
Sarah Hicks
Sarah Hicks 2018년 10월 4일
편집: Drishya Dinesh 2020년 12월 2일
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
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
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Networks에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by