using variables from workspace

I am creating a newton raphson m file which takes in two variables pressure and temperature and converges to give a correct v value using the redlich kwong equation
The inital estimate is set in the code as x=1
After one simulation the value of x converges to be more accurate is it possible to store the new variable to the workspace and use in prior simulations.
to employ a parameter sweep i.e. for value of x use as initial estimate solution just obtained for previous value of P and T.

回答 (1 件)

Walter Roberson
Walter Roberson 2023 年 3 月 9 日

0 投票

Yes, it is possible to store state information in the calling routine, but it is not recommended. It would be better to accept a parameter that is the initial location and use that, with it being the responsibility of the calling function to pass back in the previous result (or a different result if they have reason to know that the system has jumped state.)

質問済み:

2023 年 3 月 9 日

回答済み:

2023 年 3 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by