sudhakar
sudhakar

Reputation: 1

Debugging Simulink model programmatically

I have written a matlab program for a simulink model and taking control through it programmatically, but I am facing one problem while using set_param('testmodel11', 'SimulationCommand', 'start');.

It gives all the values at once, that is gives the entire scope and workplace values all at the same time, but I don't want this. I would like to run the program and execute at that point, seeing only rest of the values should be zero. How can I stop the simulation at that point and fetch plots and values from that point only, the rest should be zero. And ideally have this same behavior for the next break points too?

Upvotes: 0

Views: 922

Answers (2)

Akanksha
Akanksha

Reputation: 96

There is a way to pause the simulation at certain breakpoints (simulation points), plot the output or do whatever is desired of it, and then continue the simulation until the next breakpoint.

However, at any breakpoint, you will get output data from all the time samples till the breakpoint is reached. To isolate data from a certain timestamp, you can calculate its index based on the sample time and extract it from the workspace (output data is stored as an array)

Here is the link to my answer which will be helpful, pls go through it: https://stackoverflow.com/a/38348315/6580313

Now, in the m-file which you will run when the simulation is paused, you can change the value of the constant block which specifies the next simulation time at which simulation needs to be paused. In the m-file, you can also write a code snippet to access the output data. Once the simulation continues, it will be paused at the new simulation time specified in the constant block.

Let me know in case you have any queries.

Upvotes: 1

am304
am304

Reputation: 13876

It sounds like you want to use the Simulink Debugger. Check out the documentation for more details on how to use it. The main command-line interface to it is sldebug.

Upvotes: 0

Related Questions