multiple graphs plotting error

ro=10;
ri=30;
t=0:0.1:2000;
ci=0.5
c_L=(ci*ri)/ro.*(1-exp(1).^((-ro.*t./((ri-ro).*t+1500))));
plot(t,c_L)
hold on
ro=15;
ri=25;
c_L=(ci*ri)/ro.*(1-exp(1).^((-ro.*t./((ri-ro).*t+1500))));
plot(t,c_L)
ro=25;
ri=15;
c_L=(ci*ri)/ro.*(1-exp(1).^((-ro.*t./((ri-ro).*t+1500))));
plot(t,c_L)
For the interval t it should be 0 to 2000, but when I run MATLAB with that interval graph looks very weired
However, with interval 0 to 100 looks fine.
What should I do?

 Accepted Answer

The ‘t’ vector for the first series of curves is:
t=0:0.1:100;
and for the second:
t=0:0.1:2000;
That likely explains the difference.
To plot ‘t’ from 0 to 2000, define ‘t’ over the desired range.

6 Comments

My question was for first series t interval should be 0 to 2000 but when I run it (with 0 to 2000) graph looks very weired. But with interval 0 to 100 looks fine.
The problem is in the third plot of your original (unedited Question — I saved the previous code), specifically:
ro=25;
ri=15;
c_L=(ci*ri)/ro.*(1-exp((-ro.*t./((ri-ro).*t+1500))));
plot(t,c_L)
In the previous plots, (ro < ri) so the difference (ri-ro) was positive and the code gave you the result you want. With (ro > ri), the exponent becomes positive, and when ‘t’ is 150.6, ‘c_L’ is . I have no idea what you are calculating here, however so long as you should get the sort of result you want.
that means i cant draw graph for ro>ri?
You certainly can draw it. You just need to be prepared for results that may not be what you want. Or alternatively, use ylim to restrict the display to only positive values of ‘c_L’.
i see, thanks!
As always, my pleasure!

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!