How do I plot a function that consists of a variable depending on x?

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?

답변 (2개)

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

Thank you man! It was the matlabFunction that I needed!
Accept this Answer ?

댓글을 달려면 로그인하십시오.

Jing
Jing 2013년 1월 5일
편집: Jing 2013년 1월 5일
Hi, It should be like this:
y=@(x) x^3; fplot(y,[-10,10]);
or
fplot(@(x) x^3,[-10,10])
You need to define the function handle.

카테고리

도움말 센터File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

태그

질문:

2013년 1월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by