MATLAB: How to scan the model for parameters read/write

find_systemfindvarssimulink

Is there a way to scan a model for any blocks that would read or write parameters to workspace. I need to clean-up a large model and I want to make sure no block are using or setting some values outside of want I know or want.
The same request also for file read or write.

Best Answer

To find blocks that can read of write to worksapce or file, you may use the find_system function:
For example,
>> find_system('mymodel','BlockType','ToFile')
>> find_system('mymodel','BlockType','ToWorkspace')
>> find_system('mymodel','BlockType','FromFile')
>> find_system('mymodel','BlockType','FromWorkspace')
In addition, to find all blocks that are using variables in the workspace, you can consider using the Simulink.findVars function:
For example,
>> Simulink.findVars('mymodel','SourceType','base workspace')