MATLAB: Problem using the ‘subs’ command(Error using symengine)

error using symenginesubs

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]))

Best Answer

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)