Info

この質問は閉じられています。 編集または回答するには再度開いてください。

why i am not getting the plot while giving the following program with if else statyement?please help

1 回表示 (過去 30 日間)
an
an 2014 年 3 月 6 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
r=10; d=[1 100 1000]; P1=10^9; P2=130*10^9; s=d./r;
a=0; c=2; x=s; if (a<=x<=2); e1=1; else if (x>=2); e1=((d./r)+2)./4; else if (x>2); e1=(d./r)./4; end end end
u=e1.*P1; ug=e1.*P2; plot(d,u,'green') hold; plot(d,ug ,'red');

回答 (1 件)

Chandrasekhar
Chandrasekhar 2014 年 3 月 6 日
r=10; d=[1 100 1000]; P1=10^9; P2=130*10^9; s=d./r;
a=0; c=2; x=s;
if (a<=x<=2)
e1=1;
else if (x>=2)
e1=((d./r)+2)./4;
else if (x>2)
e1=(d./r)./4;
end
end
end
u=e1.*P1;
ug=e1.*P2;
plot(d,u,'green')
hold;
plot(d,ug ,'red');
  2 件のコメント
an
an 2014 年 3 月 6 日
still it is not showing any plots.its coming like dots only
Chandrasekhar
Chandrasekhar 2014 年 3 月 6 日
編集済み: Chandrasekhar 2014 年 3 月 6 日
yes, thats because d and u are scalars. they should be vectors if you want to represent in the form of a graph

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by