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

3 vues (au cours des 30 derniers jours)
Wesser
Wesser le 3 Mai 2022
Réponse apportée : dpb le 3 Mai 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

Réponses (1)

dpb
dpb le 3 Mai 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()

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by