MATLAB: Wait a boolean variable becomes false

MATLAB

I have connected the software Plant Simulation to Matlab and thus when I start the matlab program the simulation on Plant SImulation correctly works. However, after this simulation I have to analyse the data but matlab proceeds even if the simulation is not finished. I am thinking about using the COM-function IsSimulationRunning, which returns true if running and false if not, to say matlab to wait until this variable becomes false.
However I do not know how to do that. This because there should be a dynamic control of this variable to see if it is true or not.
How can I do that? Thanks

Best Answer

Well, you can always write a while loop that test that the property is false.
%start simulation
while yourcomobject.IsSumlationRunning
%waiting for simulation to complete
end
%simulation is no longer running
%rest of the code.
However, if your com object triggers an event when the simulation completes, you may want to listen to that event instead. Details of the event would be required to explain how to do that.