MATLAB: Is it possible to create a triggered From Workspace block in Simulink 7.3 (R2010a)

simulink

I would like to a From Workspace block that's able to reset its internal time when triggered. The block should work similarly to a repeating sequence that's controlled by an external execution signal and should obtain data from workspace.

Best Answer

The Simulink From Workspace block is not able to directly implement a triggering solution. This is due to the way this block is implemented in Simulink environment. When the model is initialized the variable is loaded from MATLAB workspace and the value can't be changed in runtime but only by stopping and starting the solver.
You can consider the following workaround based on Embedded MATLAB and a triggered subsystem. Please find the example model in Related Documents section.
The From Workspace has been replaced by a Constant block to obtain the full content of the workspace variable during initialization. Through a triggered subsystem the time when I should reset the input is calculated. This time difference is then used as an input to an Embedded MATLAB block that recreates the interpolation schema of the From Workspace block.
Please note that the Clock block is not allowed for code generation. You can consider substituting this block with a Digital Clock (with a fixed sample time) in case you need to generate code from your model.