How do I plot a function that consists of a variable depending on x?
5 views (last 30 days)
Show older comments
For example, after some calculations to solve my problem, I get y=x^3.
How do I plot that function? I tried to do fplot(@(x) y, limits) but it doesn't work...any solution?
0 Comments
Answers (2)
Walter Roberson
on 5 Jan 2013
ezplot('x^3', limits)
OR
ezplot(@(x) x.^3, limits)
OR
x = linspace(LowerLimit, UpperLimit, NumberofPoints);
plot(x, x.^3)
Or more generally if you have a symbolic variable y that contains the expression,
f = matlabFunction(y, 'x');
and then
ezplot(f, limits)
or
x = linspace(LowerLimit, UpperLimit, NumberofPoints);
plot(x, f(x))
2 Comments
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!