Filter löschen
Filter löschen

Multiple projectile plots

4 Ansichten (letzte 30 Tage)
Stuart
Stuart am 23 Mär. 2012
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.

Antworten (1)

Thomas
Thomas am 23 Mär. 2012
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 Kommentare
Stuart
Stuart am 23 Mär. 2012
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 am 23 Mär. 2012
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..

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by