Plot as not expected

10 visualizaciones (últimos 30 días)
Ra Karamislo
Ra Karamislo el 4 de Mayo de 2020
Comentada: Star Strider el 5 de Mayo de 2020
Hello
Can anybody please help me?
I am trying to plot 3 functions. I expect to see sine periodic in negative x and exponential in positive x, but matlab ignores cos.
here is my code:
t = -10:0.01:10;
A=-0.6*(cos(t)+2.*sin(t))+((-0.5+0.6)*exp(2*t));
B=-0.6*(cos(t)+2.*sin(t))+((-0.6+0.6)*exp(2*t));
C=-0.6.*(cos(t)+2.*sin(t))+((-0.7+0.6).*exp(2.*t));
plot(t, A)
hold on
plot(t, B)
plot(t, C)
grid on
Thank you
Kindest regards
Here is what I expect to see

Respuesta aceptada

Star Strider
Star Strider el 4 de Mayo de 2020
None of them are being ignored. The current y-axis limits are so large that the red line ‘C’ appears as a straight line.
Use:
ylim ([-1 1]*20)
to see all of them clearly. The complete code is then:
t = -10:0.01:10;
A=-0.6*(cos(t)+2.*sin(t))+((-0.5+0.6)*exp(2*t));
B=-0.6*(cos(t)+2.*sin(t))+((-0.6+0.6)*exp(2*t));
C=-0.6.*(cos(t)+2.*sin(t))+((-0.7+0.6).*exp(2.*t));
figure
plot(t, A)
hold on
plot(t, B)
plot(t, C)
grid on
ylim ([-1 1]*20)
producing:
.
  2 comentarios
Ra Karamislo
Ra Karamislo el 5 de Mayo de 2020
Thank you very much
Star Strider
Star Strider el 5 de Mayo de 2020
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by