Initial Conditions on the solve function?
이전 댓글 표시
Hi everyone,
I was wondering about the specifics of the 'solve' function within MATLAB. I have a series of non-linear functions (3 equations in 3 variables) that I am using 'solve' to find a solution for. However, there are multiple solutions that can work, and the 'solve' function returns the same one every time. Is there a way to specify initial conditions such that solve will return a different solution?
For example, I was playing with this the other day. Let's say I input the following:
syms x
solve('cos(x) = 0')
As we know, this has infinitely many solutions, but the solver will always return x = pi/2. Is there any way to have the solver output, for example, 3*pi/2?
Thanks in advance for all your help.
답변 (1개)
Walter Roberson
2011년 3월 5일
If you go more directly in to the toolbox, you can potentially provide a range.
feval(symengine, 'solve', sym('cos(x)'), sym('x=pi..3*pi'))
Or more compactly,
evalin(symengine, 'solve(cos(x),x=pi..3*pi)')
댓글 수: 2
Andrew Yoon
2011년 3월 5일
Walter Roberson
2011년 3월 5일
In theory you could provide a system in inequalities that constrain the range of variables; you would provide that as a cell array first argument.
In practice, I don't know. I know that Maple does not handle inequalities well, but I don't know about MuPad.
What I would suggest trying is looping over the members of the set of solutions to solving over the first variable, solve()'ing each member for the appropriate range for the second variable. The symbolic function map() should be usable to do the loop, as in
evalin(symengine,'map(solve,solve(cos(x)+cos(y),x=0..2*pi),y=0..2*pi)')
Hypothetically it should work...
카테고리
도움말 센터 및 File Exchange에서 Common Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!