what is the syntaxis for numerical solvers?

Hi, for the last hour I am trying to start the numerical solver..
The copy-past from "help"
numeric::solve([sin(x) = y^2 - 1, cos(x) = y], [x, y]);
gives
Error: Unexpected MATLAB operator
for '::'
I can also use the other syntaxis option, which works fine in my script:
syms ha r2 positive; [h,rcone] = solve( hh(ha,r2) == 0, VV(ha,r2) == V0);
If use this, how do I define the range of ha and r2 in which I want the solutions?

 채택된 답변

Petr
Petr 2012년 12월 12일

0 개 추천

thanks! but.. how to introduce the range in which I look for solutions? say, x=1..3 ? what's the syntax?

댓글 수: 3

syms x y
feval(symengine, 'numeric::solve', [sin(x) = y^2 - 1, cos(x) = y], [sym('x=1..3'), y])
Petr
Petr 2012년 12월 13일
! I found the way: using assumptions
Thanks
Note this from the numeric::solve documentation page:
Note: In contrast to the symbolic solver solve, the numerical solver does not react to properties of identifiers set via assume. To use these properties, call float ( hold( solve )(arguments)) instead.

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

추가 답변 (4개)

Azzi Abdelmalek
Azzi Abdelmalek 2012년 12월 12일
편집: Azzi Abdelmalek 2012년 12월 12일

0 개 추천

sol=solve('sin(x) = y^2 - 1', 'cos(x) = y')
%or
sol=solve('sin(x) -y^2 + 1', 'cos(x) - y')

댓글 수: 2

How do I make x the subject of this equation.using matlab
x = exp(x+y)
Walter Roberson
Walter Roberson 2018년 12월 13일
편집: Walter Roberson 2018년 12월 13일
In older versions of MATLAB,
solve('x = exp(x+y)', 'x')
In more modern versions
syms x y
solve(x == exp(x+y), x)
However, MATLAB is not able to find a solution. A solution exists, and is
-lambertw(-exp(y))
but MATLAB is not strong on Lambert W processing.

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

Zuhaib
Zuhaib 2012년 12월 12일

0 개 추천

it depend on your equation .. write function used in your equation for search in hepl of matlab
Walter Roberson
Walter Roberson 2012년 12월 12일

0 개 추천

numeric::solve is a MuPAD call that cannot be directly used from MATLAB. Use
feval(symengine, 'numeric::solve', [sym('sin(x) = y^2 - 1'), sym('cos(x) = y')], [sym('x'), sym('y')])
If you have R2011b or later (I think it is), you can use
syms x y
feval(symengine, 'numeric::solve', [sin(x) = y^2 - 1, cos(x) = y], [x, y])

댓글 수: 1

Petr
Petr 2012년 12월 13일
>> syms x y
>> feval(symengine, 'numeric::solve', [sin(x) = y^2 - 1, cos(x) = y], [x, y])
it tells
"Error: The expression to the left of the equals sign is not a valid target for an assignment." to the '=' sign after sin(x).
I tried == instead and it does not work.. Am I doing something completely wrong? Looks like all the toolboxes are installed and it is R2012a
The answer to
>> feval(symengine, 'numeric::solve', [sym('sin(x) = y^2 - 1'), sym('cos(x) = y')], [sym('x'), sym('y')])
is [ empty sym ]

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

Chibuzo Chukwu
Chibuzo Chukwu 2018년 12월 13일

0 개 추천

How do I make x the subject of this equation.using matlab
x = exp(x+y)

질문:

2012년 12월 12일

편집:

2018년 12월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by