Solve a nonlinear system

I'm solving the following as:
f = @(R01) 1/(1+R01) - .95;
R01 = fzero(f,0);
f = @(R02) 0.08/(1+R01) + 1.08/(1+R02)^2 - .99;
R02 = fzero(f,0);
How can I solve the system in one shot, can't make it work with fsolve.
Thanks
Oleg

 채택된 답변

Andrew Newell
Andrew Newell 2011년 3월 4일

0 개 추천

Is this what you're trying to do?
f = @(x) [1/(1+x(1)) - .95; 0.08/(1+x(1)) + 1.08/(1+x(2))^2 - .99];
R = fsolve(f,[0 0]);
If so, you can't do it with fzero because it only accepts a function with a scalar input and scalar output.

댓글 수: 3

Oleg Komarov
Oleg Komarov 2011년 3월 4일
Ok, now I get it...Thanks
Zulhash Uddin
Zulhash Uddin 2011년 3월 6일
After running the program, we r getting some text with the result. How can we minimize this text?
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the default value of the function tolerance, and
the problem appears regular as measured by the gradient.
<stopping criteria details>
R =
0.0526315789063412 0.0870230886539235
Andrew Newell
Andrew Newell 2011년 3월 6일
@Zulhash, could you please submit a separate question on this?

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

추가 답변 (2개)

Matt Fig
Matt Fig 2011년 3월 4일

0 개 추천

Do you mean get R01 and R02 in one shot, or do you mean find where the two functions meet (what I usually think of when someone says they want to solve a system of equations)?
If you mean, how to get to R02 in one shot,
f3 = @(R02) 0.08./(1+(1/.95-1)) + 1.08/(1+R02).^2 - .99;
R02 = fzero(f3,0)
Or,
f = @(R01) 1/(1+R01) - .95;
f = @(R02) 0.08/(1+fzero(f,0)) + 1.08/(1+R02)^2 - .99;
R02 = fzero(f,0)

댓글 수: 1

Oleg Komarov
Oleg Komarov 2011년 3월 4일
I actually wanted to use fsolve as in EXAMPLE 1 of the fcn help. Is it possible or am I attempting something senseless from a mathematical point of view?

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

Walter Roberson
Walter Roberson 2011년 3월 4일

0 개 추천

With the symbolic toolkit, it looks like
solve(0.8e-1/(1+solve(1/(1+RO1)-.95))+1.08/(1+R02)^2-.99)
and gives the values -2.087023117, 0.08702311660

카테고리

도움말 센터File Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by