Multiple projectile plots

조회 수: 5 (최근 30일)
Stuart
Stuart 2012년 3월 23일
Hi, I'm trying to plot multiple projectiles on a graph. The projectiles at launched between 60 and 80 degrees with a one degree increment.
The launch velocity is specified by the Lanunch angle, to ensure it reaches the desired coordinates (6.7,3.05).
So the (x,y)graph I wanted would show 21 different trajectories.
However when I put my code in, Matblab only plots one line and I'm not really sure what it represents.
My code is:
%Angles of Projectile theta=[60:1:80];
%Launch velocity from given theta u=((((9.81/2)*1.25.^2)*(1+(tand(theta)).^2)./((1.25*tand(theta))-0.55))').^(0.5);
%Horizontal positions x=[0:0.335:6.7];
%Vertical Positions y=(x*tand(theta)')-((9.81/2)*(x.^2))./(((u.^2).*(cosd(theta))'.^2)')+2.5;
%Graph of projectiles plot(x,y)
Can anyone point out my error or what I should do? Thanks.

답변 (1개)

Thomas
Thomas 2012년 3월 23일
My understanding is that you change the theta and the x values..
declare theta and x
for change in theta
for change in x
compute u % remember to get u as vector u(i) or u(j)
compute y % remember to get y as vector y(i) or y(j)
end % to compute at this theta and all values of x giving you
%one set of values of y
plot(x,y) % to plot the first curve
hold on % to show more curves on same graph
end % to go to next value of theta and repeat
  댓글 수: 2
Stuart
Stuart 2012년 3월 23일
Thanks Thomas,
I'm not really sure how I should add this into my code.
Should I enter u(i) and y(i)?
Thomas
Thomas 2012년 3월 23일
Think about how you get a vector for y?
You can svae the output in a vector or matrix as shown,
Eg:
for i=1:10
y(i)=i+rand; % us y(i) so that it is written as a vector
end
or you could use:
z=[];
for i=1:10
z=[z i+rand];
end
both should give you similar results..

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

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by