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