'solve' Command - Only shows one value

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

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?
Cristian
Cristian 2012년 11월 18일
편집: Cristian 2012년 11월 18일
My error. Excuse me.
double(solve('1=2*sin(m)'))
Without the dot.
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
Walter Roberson 2012년 11월 18일
The equals sign can appear in modern MATLAB.

댓글을 달려면 로그인하십시오.

답변 (2개)

Walter Roberson
Walter Roberson 2012년 11월 18일

1 개 추천

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
bym 2012년 11월 18일

0 개 추천

try this (without using string input)
syms t
>> double(solve(1-2.*sin(t)))
ans =
0.5236
2.6180

댓글 수: 5

Hi.
This line produces me the same output as the first code.
>> syms t;
>> double(solve(1-2.*sin(t)))
ans =
0.5236
Another question. What is the function of syms t?
Thanks.
syms t % constructs a symbolic object
what does
solve(1-2*sin(t))
return?
This:
>> solve('1-2*sin(t)')
ans =
1/6*pi
Walter Roberson
Walter Roberson 2012년 11월 18일
Which MATLAB version are you using?
Cristian
Cristian 2012년 11월 18일
Version 7.0

댓글을 달려면 로그인하십시오.

제품

태그

질문:

2012년 11월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by