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.

Respuestas (1)

Walter Roberson
Walter Roberson el 9 de Mzo. de 2023

0 votos

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.)

Preguntada:

el 9 de Mzo. de 2023

Respondida:

el 9 de Mzo. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by