I am unable to display my output for my graph.

1 vue (au cours des 30 derniers jours)
Richard Buccacio
Richard Buccacio le 24 Sep 2021
Modifié(e) : per isakson le 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;

Réponse acceptée

Sulaymon Eshkabilov
Sulaymon Eshkabilov le 24 Sep 2021
Modifié(e) : Sulaymon Eshkabilov le 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

Plus de réponses (1)

Walter Roberson
Walter Roberson le 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;
  1 commentaire
per isakson
per isakson le 28 Sep 2021
endfor or endif are Octave keywords. Matlab uses end.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Antennas, Microphones, and Sonar Transducers dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by