Problem using the 'subs' command(Error using symengine)
20 次查看(过去 30 天)
显示 更早的评论
I am trying to solve the cubic equation 0.75*k*B1^3 -m*w^2*B1 + c*B1 - A == 0 and get the absolute number for the roots. However, I encounter "Error using symengine" when I try to use replace the 'k' symbolic variable with 0 using 'subs' command. Below is my code. There is no problem if I enter some value other than 0 in the code.
syms A m c k w B1
eqn = 0.75*k*B1^3 -m*w^2*B1 + c*B1 - A == 0
sol = solve(eqn,B1)
root = abs(subs(sol, [k,m,c,A], [0,1,1,1]))
And below is the errors that I got:
Error using symengine The third argument must be an integer between 1 and the degree of the polynomial.
Error in sym/subs>mupadsubs (line 140) G = mupadmex('symobj::fullsubs',F.s,X2,Y2);
Error in sym/subs (line 125) G = mupadsubs(F,X,Y);
Error in NonlinearStudy (line 9) root = abs(subs(sol, [k,m,c,A], [0,1,1,1]))
0 个评论
采纳的回答
Birdman
2017-12-12
You should use subs command for coefficients before solving the equation.
syms A m c k w B1
eqn = 0.75*k*B1^3 -m*w^2*B1 + c*B1 - A == 0
eqn = subs(eqn,{k,m,c,A},{0,1,1,1})
sol = solve(eqn,B1)
0 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!