Problem using the 'subs' command(Error using symengine)

조회 수: 20 (최근 30일)
Jen Cong Wong
Jen Cong Wong 2017년 12월 11일
답변: Birdman 2017년 12월 12일
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]))

채택된 답변

Birdman
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개)

카테고리

Help CenterFile Exchange에서 Conversion Between Symbolic and Numeric에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by