Azzera filtri
Azzera filtri

Solve command for cubic equation isnt working

2 visualizzazioni (ultimi 30 giorni)
Vivi
Vivi il 8 Feb 2020
Risposto: Walter Roberson il 8 Feb 2020
Hello,
I am trying to sovle a cubic equation for both real and imaginary roots in matlab by executing the following commands :
d=-10:0.01:10;
l=-100:0.1:100;
eqn=l.^3-d.*(l.^2)+1 ==0
s=solve(eqn)
I tried to insert as a second variable in the sovle command the variable " l " but its not working either. When i am trying to run the command by using as a second variable the variable " l " ive got the following error :
" Error using sym.getEqnsVars>checkVariables (line 87)
Second argument must be a vector of symbolic variables.
Error in sym.getEqnsVars (line 54)
checkVariables(vars);
Error in solve>getEqns (line 429)
[eqns, vars] = sym.getEqnsVars(argv{:});
Error in solve (line 226)
[eqns,vars,options] = getEqns(varargin{:});
Error in Solution_full (line 44)
s=solve(eqn,l) "
Can anyone give me a clue of how i will solve that equation or why i am getting the above errors?
Thank you

Risposte (1)

Walter Roberson
Walter Roberson il 8 Feb 2020
Your l and d are numeric. Your comparison gives logical results. You are trying to solve() an array of logical values. solve() requires that the first parameter to it be symbolic expression or symbolic function.
You should define a symbolic expression and solve that, and then subs() in numeric values for the variables.

Categorie

Scopri di più su Symbolic Math Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by