MATLAB: How to import matlab file variables in Simulink (By adding some block in Simulink Model)

simulink

I have seen in some Simulink Model, there was a block with the M-File. You just double click that file, it gets executed and variables are available for Simulink Model. Can anybody help me to find the way to do it. Thanks

Best Answer

That is probably a customized mask of a subsystem block. Assume the M-file you want to run is MyParam.m, you can drag an empty subsystem block, right click, select 'block properties', select 'Callbacks' tab, select 'OpenFcn', type in MyParam.
You can even mask it by select the block, press ctrl+M, in the 'Drawing Commands', put in disp('MyParam').
Related Question