Graph plot always appears as a straight line

11 ビュー (過去 30 日間)
Abhinandana R
Abhinandana R 2019 年 1 月 23 日
コメント済み: Abhinandana R 2019 年 1 月 23 日
Hi, I don't know how to fix this. y graph looks like a straight line instead of an exponential curve. Please help me.. thanks a lot in advance !
l=0.5;
i=22/7;
v=0.8;
p=0.1;
x=[0:0.2:1.0];
y=(p*r^4*x)/(8*v*l);
plot(x,y)
  5 件のコメント
Abhinandana R
Abhinandana R 2019 年 1 月 23 日
ok sir.. now I got it. but how can I change it ?
madhan ravi
madhan ravi 2019 年 1 月 23 日
see Rik Wisselink’s answer below

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

採用された回答

Rik
Rik 2019 年 1 月 23 日
You are varying x, instead of r. The code below shows how you could edit your code to plot y as a function of r.
l=0.5;
i=22/7;
v=0.8;
p=0.1;
x=0.1;
n_r_steps=100;
r=linspace(0,1,n_r_steps);
y=(p*r.^4*x)/(8*v*l);
plot(r,y)
  3 件のコメント
Rik
Rik 2019 年 1 月 23 日
If you run this code, it will plot the graph in the current axis. If it does not exist, it will create one.
I don't know how you would manage to have this make any output in the command window, unless you have a variable with the name plot.
Abhinandana R
Abhinandana R 2019 年 1 月 23 日
I was totally blank of this software sir. but now somehow I got cleared and I got the expected graph sir. thanks a lot !

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

その他の回答 (1 件)

Kevin Phung
Kevin Phung 2019 年 1 月 23 日
編集済み: Kevin Phung 2019 年 1 月 23 日
if r is a constant, you will get a straight line. if r varies, then you will get a curve.
also, you may want to add a period before your raising to a power and multiplcation for non-scalars.
so .^ and .*

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by