Is there programmatic access to the Simulink SimulationManager information or another way to monitor the progress of a sim(SimulationInput)?
2 次查看（过去 30 天）
I have a process setup to run a series of simulations using the sim(mySims) using the Simulink.Simulation input object. I would like to be able to have another function / process / something monitor the progress and provide status updates. I am doing lots of batch things and do not really care to see the built in SimulationManager gui, and it doesn't give me a way to send updates to an external sources.
I could potentially use the Simulink.SimulationInput.setPostSimFcn, but I am already using that for the individual sims to do some processing for smaller sets, and I do not need the updates from those. So I'd like to not modify that function.
So is there a way to overwrite the SimulationManager with my own monitoring function?
Suman Sahu 2023-8-17
Since you are doing simulations in batch, I am assuming you are using ‘batchsim’ function. Using the ‘batchsim‘ function you can only get the ‘RunningDuration’ of the batch job. Only once the job has finished, meaning all the simulations are in ‘finished’ state, you can see the individual ‘SimulationOutput’s results and timing info.
‘batchsim’ function returns a ‘Simulink.Simulation.Job’ object which gives the ‘RunningTime’ info for the job while it is in ‘running’ State.
Once the job’s ‘State’ value is ‘finished’, you can use the ‘fetchOutputs(Simulink.Simulation.Job)’ function which returns an array of ‘Simulink.SimulationOutput’ objects containing the results of the individual simulations in the batch job.
Since you can only see the individual simulation results only after the batch job is finished, it may not help you in monitoring purposes.
You can try to use the ‘parsim’ function where you can asynchronously fetch the individual simulation results as they complete using the ‘fetchNext(Future)’ function. It can help you monitor how many of the simulations have finished. To learn more about it refer to the following documentation: Fetch next available unread output from Simulink.Simulation.Future object array - MATLAB fetchNext
Hope it was helpful