I am unable to display my output for my graph.

1 visualización (últimos 30 días)
Richard Buccacio
Richard Buccacio el 24 de Sept. de 2021
Editada: per isakson el 28 de Sept. de 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;

Respuesta aceptada

Sulaymon Eshkabilov
Sulaymon Eshkabilov el 24 de Sept. de 2021
Editada: Sulaymon Eshkabilov el 24 de Sept. de 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

Más respuestas (1)

Walter Roberson
Walter Roberson el 24 de Sept. de 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 comentario
per isakson
per isakson el 28 de Sept. de 2021
endfor or endif are Octave keywords. Matlab uses end.

Iniciar sesión para comentar.

Categorías

Más información sobre Antennas, Microphones, and Sonar Transducers en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by