Struggling with simulation flow control commands in Simulink!

1 view (last 30 days)
Dear Community,
Some time ago I found Set_param to control Simulation flow of my Simulink block diagram through an m-file. It is an interesting tool specially for control engineering applications. After some time benefiting from this tool I found an inefficiency in it and would like to explain — may one has a solution. I already tried to report the problem in a previous thread but it seems it couldn't get noticed. So, I will try a different wording here.
I have a Constant block in my diagram connected to a continuous subsystem as the input. The solver is set to be ode45 and I need to feed my plant on a discrete basis with 0.01 as the sampling rate. There is an assertion block in my diagram that runs set_param(mdl, 'SimulationCommand', 'pause') at every sampling instant to pause the simulation flow and give time to the m-file to compute the next input. After computing the next input, the m-file writes it to the constant block and updates the simulation command. Here I notice that the block variable gets updated but its output signal doesn't. When I continue the simulation flow the new value will take effect since the next sampling instant (I don't know why). Many might not even notice this but in a control engineering application this adds an undesired pure delay to the system.
It seems to me that set_param(mdl, 'SimulationComand', 'update') fails to update signals immediately after the block parameter value is updated.
I guess there might be a solution to this maybe by accessing methods of the class simulink.BlockDiagram.
I run MATLAB 2016a on WIN 8.1.

Answers (0)

Categories

Find more on General Applications in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!