I am unable to display my output for my graph.

1 Ansicht (letzte 30 Tage)
Richard Buccacio
Richard Buccacio am 24 Sep. 2021
Bearbeitet: per isakson am 28 Sep. 2021
Why is the following not displaying my output? Please help.
t = [0:0.01:20];
Vo = 90;
angle = [10 25 45 65 85];
g = 9.81;
yo = 0; mm = 0;
for theta = angle
Xposition = Vo*cosd(theta)*t;
Yposition = ( -(1/2)*g*(t.^2) ) + Vo*sind(theta)*t + yo;
plot(t,Yposition,'DisplayName',int2str(theta));
if max(Yposition(Yposition>=1)) > mm
mm = max(Yposition);
endif
hold on;
endfor
axis([0 inf 0 mm+20])
xlabel('Time(s)');
ylabel('Projectile Height(m)')
legend hold off;

Akzeptierte Antwort

Sulaymon Eshkabilov
Sulaymon Eshkabilov am 24 Sep. 2021
Bearbeitet: Sulaymon Eshkabilov am 24 Sep. 2021
Here is a corrected code:
t = 0:0.01:20;
Vo = 90;
angle = [10 25 45 65 85];
g = 9.81; yo = 0; mm = 0;
for theta = angle
Xposition = Vo*cosd(theta)*t;
Yposition = ( -(1/2)*g*(t.^2) ) + Vo*sind(theta)*t + yo;
plot(t,Yposition,'DisplayName',int2str(theta));
if max(Yposition(Yposition>=1)) > mm
mm = max(Yposition);
end
axis([0 inf 0 mm+20])
xlabel('Time(s)');
ylabel('Projectile Height(m)')
hold on
end
legend
hold off

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 24 Sep. 2021
Because MATLAB does not have endfor or endif commands.
t = [0:0.01:20];
Vo = 90;
angle = [10 25 45 65 85];
g = 9.81;
yo = 0;
mm = 0;
for theta = angle
Xposition = Vo*cosd(theta)*t;
Yposition = ( -(1/2)*g*(t.^2) ) + Vo*sind(theta)*t + yo;
plot(t,Yposition,'DisplayName',int2str(theta));
if max(Yposition(Yposition>=1)) > mm
mm = max(Yposition);
end
hold on;
end
axis([0 inf 0 mm+20])
xlabel('Time(s)');
ylabel('Projectile Height(m)')
legend
hold off;

Kategorien

Mehr zu Antennas, Microphones, and Sonar Transducers finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by