Why is my last line coming up as an empty sym?

1 次查看(过去 30 天)
There's a couple steps to this problem. Expand and then simplify the equation. The last is to solve this equation: when x =2. But when I run it, it comes up empty
𝑦= (𝑥^3 +1)(𝑥^2 +2𝑥−5)(𝑥^2 −3)^2
clear
syms x
x==2
y = (x^3+1)*(x^2+2*x-5)*(x^2-3)^2 %deleted "eqn =' double = leads to error
expand(y) %switch out "eqn" with "y"
simplify(y) %same as above
solve(subs(y,x,2),y)

回答(1 个)

Cris LaPierre
Cris LaPierre 2021-10-22
I don't think you need to use solve in the final line. Substituting in 2 for x will return a value for y. There is nothing left to solve for.
syms x
y = (x^3+1)*(x^2+2*x-5)*(x^2-3)^2 %deleted "eqn =' double = leads to error
y = 
subs(y,x,2)
ans = 
27

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by