# Iterative solution of non-linear equation with a provided guess value?

조회 수: 2(최근 30일)
Raihan Rahmat Rabi 2021년 7월 23일
답변: Matt J 2021년 7월 24일
I am looking for a solution to the problem:
ag_p*Gamma_p - Sa = 0 with Gamma_p = A+B*ag_p.
A, B and Sa are constants.
This can be solved by performing iterations starting with a certain guess value for ag_p.
Note: I have solved it through FZERO function as given below. I am interested to iteratively solve the equation by assigning a guess value to ag_p, let's say from [0...inf], which updates Gamma_p and the iterations are performed until the solution is found ( Something similar to Solve Block in MathCAD). I need to have a numerical value for Gamma_p in each iteration because I will be comparing its value with another constant parameter to define some "if" conditions.
Sa = 2.7956;
A = 2.24;
B = 0.5547;
Gamma_p = @(ag_p) A+B*ag_p;
f = @(ag_p) ag_p*Gamma_p(ag_p) - Sa;
z = fzero(@(ag_p) f(ag_p), 1E-3)
Thank you,

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

### 답변(2개)

Matt J 2021년 7월 23일
편집: Matt J 2021년 7월 23일
Using fsolve() instead of fzero(), you could solve the problem as a system of two equations in two unknowns. The two unknowns are [ag_p, Gamma_p] and the two equations are,
ag_p*Gamma_p - Sa = 0
B*ag_p + A - Gamma_p = 0
##### 댓글 수: 0표시숨기기 이전 댓글 수: -1

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

Matt J 2021년 7월 24일
You could use fzero's OutputFcn option
to access the sequence of ag_p iterates. It is then a simple matter to generate the corresponding sequence of Gamma_p values using the equation Gamma_p = A+B*ag_p.

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

### Community Treasure Hunt

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

Start Hunting!

Translated by