Why is my fplot not working?
显示 更早的评论
My fplot is not working in my code. A few minutes ago, the code was plotting the graph just fine, but now it isn't. I can't figure out what is wrong. Matlab keeps saying that "Second argument must be a scalar or vector of unique symbolic variables."
%Symbolically find the roots of the following equation using 'solve'
syms x y(x)
y(x)=x^3+1
solve(x^3+1)
%Find what y equals when x=0
subs(y,x,0)
%Graph the equation on the interval [-10,10]
fplot(y,[-10,10],'b')
3 个评论
Star Strider
2020-2-1
Your code works when I run it (R2019b).
Note that ‘y’ has three roots, two being complex:
syms x y(x)
y(x)=x^3+1
y0 = vpasolve(x^3+1)
figure
fplot(y,[-10,10],'b')
producing:
y0 =
-1.0
0.5 - 0.86602540378443864676372317075294i
0.5 + 0.86602540378443864676372317075294i
and the figure.
Kyle Donk
2020-2-1
Star Strider
2020-2-1
That’s the reason I always use figure to create a new one for each plot. Otherwise, MATLAB uses the existing axes.
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!