
Plot as not expected
10 views (last 30 days)
Show older comments
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

0 Comments
Accepted Answer
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
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!