How can I plot the following function in MATLAB?
x = 0:20:200;
y = 1+((x/8)^(1/3))+((8/x)^(1/3));`
I tried it using plot(x,y)
, but it doesn't run any output. Any help?
You should change all operators that get x
to elements-wise . this is done by adding .
before the operator. So *
is matrix multiplication, while .*
is an element by element multiplication. This is true also for ^
and /
. +
and -
are always element-wise. For .*
the two inputs must be the same size and shape, or one of them is a scalar. For .^
and ./
it's better to always use them if you know that you are only dealing with array operations (unless both elements are scalars).
x = 0:20:200;
y = 1+((x./8).^(1/3))+((8./x).^(1/3));
plot(x,y)
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.