I am trying to do a loop simulation: in loop, I need to run a matlab script to generate some parameter for the next loop and feed back to the loop.
However, I found, Ptolemy does not run as I expected. The matlab module actually takes all the data (for the total number of samples as I specified in DF) at one time. It does not process sample by sample.
Can anyone tell me how to fix this? Thanks very much.
However, I found, Ptolemy does not run as I expected. The matlab module actually takes all the data (for the total number of samples as I specified in DF) at one time. It does not process sample by sample.
Can anyone tell me how to fix this? Thanks very much.
If you are doing a swept simulation (using the ParamSweep controller) then it is possible to have parameters of certain components read their values from an initial file, then have each simulation in the sweep produce a new file with new parameter values that will be read during the next simulation in the sweep. In order for this to work, I believe the files names should be different (e.g. MyFile0, MyFile1, MyFile2, MyFile3, etc.). Otherwise, there may be a problem trying to read and write the same file at the same time. So the way this will work is that the first simulation in the sweep will read the values from MyFile0 (must exist before the simulation starts) and it will create MyFile1, which will be used in the second simulation, which will create MyFile2, etc.
However, if you are trying to update the values of component parameters during a single simulation, then this is NOT supported. The values of paratemeters of all Ptolemy models are evaluate only once at the simulation initialization and cannot be updated during the simulation run.
This has nothing to do with how the MATLAB cosimulation block works. This block can process sample by sample or blocks of samples at a time.