'solve' Command - Only shows one value
Ältere Kommentare anzeigen
Hi,
In another pc where I test this line:
double(solve('1=2.*sin(m)'))
Return values are 0.5236 and 2.6180. However, in my computer only returns the 0.5236 value. How I show the second value?
Thank you.
4 Kommentare
Oleg Komarov
am 18 Nov. 2012
I get an error:
Error using solve>processString (line 337)
' 1=2.*sin(m) ' is not a valid expression or equation.
What is your MATLAB version?
bym
am 18 Nov. 2012
the documentation says the string can not contain an equals sign. Here are my results (R2008b)
solve('1-2*sin(x)')
ans =
pi/6
(5*pi)/6
Walter Roberson
am 18 Nov. 2012
The equals sign can appear in modern MATLAB.
Antworten (2)
Walter Roberson
am 18 Nov. 2012
MATLAB 7.0 used Maple for its Symbolic Mathematics Toolbox. Maple only bothers to find a single value in this situation. When Maple is asked to find AllSolutions, it says they are
(1/6)*Pi + (2/3)*Pi*_B1 + 2*Pi*_Z1
The way to read this is that _B1 can be 0 or 1, and _Z1 is any integer (positive or negative). So solutions are at
[...], -11*Pi/6, -7*Pi/6, Pi/6, 5*Pi/6, 13*Pi/6, 17*Pi/6, [...]
bym
am 18 Nov. 2012
try this (without using string input)
syms t
>> double(solve(1-2.*sin(t)))
ans =
0.5236
2.6180
5 Kommentare
Cristian
am 18 Nov. 2012
bym
am 18 Nov. 2012
syms t % constructs a symbolic object
what does
solve(1-2*sin(t))
return?
Cristian
am 18 Nov. 2012
Walter Roberson
am 18 Nov. 2012
Which MATLAB version are you using?
Cristian
am 18 Nov. 2012
Kategorien
Mehr zu Common Operations finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!