plot when a value of zero makes issue

my code below is supposed to plot different graph with different value of t:
many thanks
c=2;
nu = 1*1e-6;
r = linspace(0,100);
t=[1/2 1 2 6 10 20 50 ];
for count=1:7
v = c * (1-exp(-r.^2./(4*nu*t(count))))./r;
plot(r,v,'o-')
legend([' t= ',num2str(t(count))])
legend show
ylabel('v(m/sec)')
xlabel('r(m)')
grid on
hold on
end

 採用された回答

David Hill
David Hill 2020 年 8 月 27 日

0 投票

If you change your nu to something more reasonable, it provides the graphs dynamics you are looking for.
nu=10;

4 件のコメント

David Hill
David Hill 2020 年 8 月 27 日
c=2;
nu = 10;
r = linspace(0,100);
t=[1/2 1 2 6 10 20 50 ];
hold on;
for count=1:7
v = c * (1-exp(-r.^2./(4*nu*t(count))))./r;
plot(r,v,'o-');
end
legend([' t= ',num2str(t(1))],[' t= ',num2str(t(2))],[' t= ',num2str(t(3))],[' t= ',num2str(t(4))],[' t= ',num2str(t(5))],[' t= ',num2str(t(6))],[' t= ',num2str(t(7))]);
legend show;
ylabel('v(m/sec)');
xlabel('r(m)');
grid on;
H-M
H-M 2020 年 8 月 28 日
Thank you so much David for your help.It works perfect.
would you please explain why hold on shoul be before the loop?
David Hill
David Hill 2020 年 8 月 28 日
No reason to execute hold commend multiple times in the loop. Once is enough.
H-M
H-M 2020 年 8 月 28 日
Thank you so much David

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange2-D and 3-D Plots についてさらに検索

タグ

質問済み:

H-M
2020 年 8 月 27 日

編集済み:

H-M
2020 年 8 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by