Which documentation and example can I use for iterative solution.

1 view (last 30 days)
Dear expert,
I was struglling with my matlab model. I have a cascade of functions which each set of function recieves the outputs of the other function as an input arguments. To run all these cascaded functions, the first set of functions needs guess values. The outputs of this functions set should be used as inputs for the next set of functions and continue like this untill the final part. Then the outputs of the last set of functions should be the same with guessed values in the begining using iterative approach. This will be the solution of my model. However, I don't know how to make an iterative solution for this problem which will stop iterating when the guess value is equal to the final calculated value (the difference between them converges to zero).
Can someone help me with examples or which documentation can I use, please? I thank you a lot in advance.
N.B I can share codes but it is too much for help.
  12 Comments
Torsten
Torsten on 12 Jan 2023
Edited: Torsten on 12 Jan 2023
It's not unusual that you get different results from "fsolve" if you use different initial guesses for the solution.
In the list of return parameters, you should check "exitflag" and "fval" to get an idea of whether "fsolve" succeeded or not.
Since "fsolve" wants to make the residuals equal to 0, it's not necessary to square y(1:3) - Cp_guess(1:3) elementwise. Just use
sol = Cp_calc(1:3) - Cp_guess(1:3)
Tadele
Tadele on 12 Jan 2023
Edited: Tadele on 12 Jan 2023
That is a very good point. I will check the return parameters. I will also use just y(1:3) - Cp_guess(1:3) without squaring.
Thank you very much, Torsten. It helps me a lot.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!