Plot as not expected

10 views (last 30 days)
Ra Karamislo
Ra Karamislo on 4 May 2020
Commented: Star Strider on 5 May 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

Accepted Answer

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

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!