Graph plot always appears as a straight line

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 Comments

Stephen23
Stephen23 on 23 Jan 2019
Edited: Stephen23 on 23 Jan 2019
What is r ?
Your function of x looks linear because it is linear in x:
y=(p*r^4*x)/(8*v*l);
% ^ independent variable
The independent variable x is to the power 1, which is linear. I don't see why you expect a non-linear curve from power 1.
sir actually I need a graph that looks like a curve for the following equation
Tex2Img_1548261667.jpg
I'm new to this software sir. I tried the above coding as per my knowledge. This equation is a function of r sir(y varies according to r). so now ,can we draw a graph that looks like a curve? if yes, kindly suggest me the coding sir. it will be helpful for my project work sir and we can give any values to the variables r, x, u and l.
"y varies according to r"
But what you calculated is y varing with x.
ok sir.. now I got it. but how can I change it ?
see Rik Wisselink’s answer below

Sign in to comment.

 Accepted Answer

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 Comments

thanks a lot sir. but it gives the value in the command window instead of graph.
I need a graph for the below equation sir. can you suggest a coding for this??
Tex2Img_1548261667.jpg
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.
I was totally blank of this software sir. but now somehow I got cleared and I got the expected graph sir. thanks a lot !

Sign in to comment.

More Answers (1)

Kevin Phung
Kevin Phung on 23 Jan 2019
Edited: Kevin Phung on 23 Jan 2019
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 .*

Categories

Asked:

on 23 Jan 2019

Commented:

on 23 Jan 2019

Community Treasure Hunt

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

Start Hunting!