MATLAB: How to make the mask initialization function to be executed when there is a change in the mask parameters

simulink

I have a subsystem where the number of inports and outports are configured by some scripts based on the parameters set in the mask. These scripts are called in the mask initialization function. If there was no change in the mask parameters there is no need to execute all the configuration scripts. This would not happen if there is a callback which is only executed when there was a change in the mask parameters.

Best Answer

You can use a flag which determines if there was a change of the mask parameters. Then you could put some of your code from the mask initialization function into a if-statement based on the flag. So not all of the initalization code would be executed at every simulation.