More specifically, I would like to automatically clear the workspace and all functions before a Simulink simulation starts. Is this possible? Are there hooks where I can define functions to be called before and, say, after开发者_运维问答 each simulation?
You can do this using model callbacks.
You can set callbacks programmatically as described on the linked page, or just right-click on an empty spot in your model file, select Model Properties, then the Callbacks tab and enter the name of the function to be called after selecting the appropriate callback in the left pane.
In your case, the StartFcn
callback seems appropriate.
精彩评论