Plot as not expected

10 Ansichten (letzte 30 Tage)
Ra Karamislo
Ra Karamislo am 4 Mai 2020
Kommentiert: Star Strider am 5 Mai 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

Akzeptierte Antwort

Star Strider
Star Strider am 4 Mai 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 Kommentare
Ra Karamislo
Ra Karamislo am 5 Mai 2020
Thank you very much
Star Strider
Star Strider am 5 Mai 2020
As always, my pleasure!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB 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