I need to plot this equation : (y)/[(4*3.14*10^-7)*(1+(4200/(1+0.03(y^8.2))^0.5))]
on the interval y=0
to y=3
I tried this
y=0:0.5:1:1.5:2:2.5:3;
x=(y)./((4*3.14*10.^-7)*(1+(4200./(1+0.03*y.^8.2).^0.5)));
plot(x,y)
Your plot
is fine, only your y
is defined problematically: the syntax is var=from:step:to
, no additional colons needed. So you either say
y=[0 0.5 1 1.5 2 2.5 3];
or, what's much better,
y=0:0.5:3;
or, what's equivalent now,
y=linspace(0,3,7);
Note that the last form will make it easy for you to produce a finer graph of your function (since plot
by default will draw you a piecewise linear function, ie connect the points with line segments). So you might want to increase the number of points from 7
to something larger, like 50
.
NO wait, there's also a slight problem: you should have .*
instead of *
in the definition of x
, like every other operation is also prepended with a .
(to make those operations element-wise array operations).
AND you have to plot(y,x)
as that seems to be the order of your function: y
is independent and x
is the value of the function.
Fixed version:
y=linspace(0,3,50);
x=(y)./((4*3.14*10.^-7).*(1+(4200./(1+0.03*y.^8.2).^0.5)));
plot(y,x)
xlabel('y')
ylabel('x(y)'); %for clarity
Result:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.