I need to solve for the one variable (sw) and get a numerical answer for it. All other variables are known but I am trying to keep a generalized code. I think I might be using the wrong function. Please help!
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
dan
am 10 Feb. 2018
Kommentiert: Walter Roberson
am 10 Feb. 2018
syms sw
tc=0.058;
ka=0.87;
M=.85;
CL=.75;
eqns=((ka/(cos(sw)))-(tc/(cos(sw).^2))-(CL/(10*cos(sw).^3)))==M;
solsw=solve(eqns,sw);

Akzeptierte Antwort
Walter Roberson
am 10 Feb. 2018
solsw = solve(eqns, sw, 'maxdegree', 3);
sort(double(solsw))
6 solutions, one of which is negative.
2 Kommentare
Walter Roberson
am 10 Feb. 2018
"'MaxDegree' — Maximum degree of polynomial equations for which solver uses explicit formulas
Maximum degree of polynomial equations for which solver uses explicit formulas, specified as a positive integer smaller than 5. The solver does not use explicit formulas that involve radicals when solving polynomial equations of a degree larger than the specified value."
That is, your previous code was not wrong -- but you are defining something that is at least a cubic polynomial because of the cos^3 . There are explicit representations known for cubics and quartics, but they are long, and most of the time writing them out explicitly just gets in the way of understanding the equation. So for anything over degree 2, most of the time MATLAB puts in a placeholder root() function instead of expanding out the solution.
In the symbolic toolbox, root(expression in z,z) stands in for "the set of values of z such that the expression becomes 0" -- that is, for the roots of the given equation. The symbolic toolbox knows how to manipulate those root() placeholders appropriately.
However, left to itself, sometimes the symbolic toolbox only outputs one root; if you ask for a MaxDegree of 3 or 4 and the expression can be written out explicitly with that, then it will list all of the roots by their formulas, allowing you to ask for specific numeric values for all of the possibilities.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Equation Solving finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!