How to couple Matlab to other model for monte carlo simulations??

1 visualización (últimos 30 días)
Wesser
Wesser el 3 de Mayo de 2022
Respondida: dpb el 3 de Mayo de 2022
Hi,
I am using Hydrus to simulate 1D unsaturated water flow. I would like to create a matlab file that can call the hydrus .exe, run the program with a set of parameters, save the output, then run the program again with another set of paramters, save, etc. I have run monte carlo simulations in .m files before (like below), but I don't know how to call another program, run the MC iteration, save, and repeat. Any guidance on how to script this would be appreciated!!!
Thanks
MC_Iterations=10000; %number of monte carlo iterations
for i=(1:MC_Iterations) %uniform distribution between low/high end members of MC ranges
vGAlpha = unifrnd(0.00001,110); %Range of Van Genuchten Alpha values
n = unifrnd(0.00001,110); %Range of Van Genuchten n values
SatK = unifrnd(0.00001,110); %Range of saturated hydraulic conductivity values
LongDisp = unifrnd(0.00001,110); %Range of longitudinal dispersivity values
Kd_solid = unifrnd(0.00001,110); %Range of solid phase sorption values
KineticAlpha = unifrnd(0.00001,110); %Range of time dependant solid phase sorption vlues
Kd_awi = unifrnd(0.00001,10); %Range of air water interfacial sorption values
end

Respuestas (1)

dpb
dpb el 3 de Mayo de 2022
That all depends on how the other application reads/writes its input/output. If it uses files and you can specify the input/output files and simply writing those output files for later post-processing is sufficient, it's pretty straightforward.
If it's interactive user input, it's a lot more complicated if doable at all...
We don't have sufficient info to respond in detail, but the basic idea will be to write a string that you pass to the OS to dispatch the other code with system()

Categorías

Más información sobre Simulation en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by