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?

 采纳的回答

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 个评论

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’.
As always, my pleasure!

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by