modelName - String input of the model name.
This function is an attempt to highlight the blocks those are not contributing to the model simulation directly.
This function is also useful to study the impact of optimization settings of model configuration parameters.
We can identify whether a block is used during the model simulation and it is not optimized by the following methods.
1. If we can setup add_exec_event_listener for the block
2. If we can get the run time object of the block.
The tool uses the second method. Because with the first one, the script can't be used more than once in the same session.
If used it would highlight all the blocks as it can't add the listed again.
Please go through the help >>help add_exec_event_listener.
Sample: Unzip the contents and run hilite_virtual_blocks('check_path') in the MATLAB command prompt. Note: 'check_path' is a sample model in the attachment.
Please compare the Simulink block sorted order for the same. This gives some idea on how the Simulink engine works.
---- Sorted list for 'check_path' [2 nonvirtual blocks, directFeed=0]
0:0 'check_path/Constant' (Constant, tid=-2)
0:1 'check_path/Scope' (Scope, tid=1)
Call the function again by changing the optimization settings and find the differences from the previous run.
Play it with a larger model. This function potentially can be used for studying model coverage.
- It will not work across model reference boundaries. Hence it has to be executed for the referenced models manually.
- The automation creates unsaved changes, but the changes can be ignored.
- Model should be simulatable.
Please feel free to improve it and add your comments.
Thanks to Murali Mohan, Will Campbell and mohmmud for your comments and ratings.
@Will Campbell - Here are the responses to your comments.
1. The tool might have highlighted all the blocks, because you might have run the function more than once in the same session. The tool is modified to use "RuntimeObject" to identify the virtual blocks instead of using "add_exec_event_listener". This change avoids this issue. Please let me know if the issue still present.
2. You comments related to model reference block is correct. It will not scan through the model reference blocks. For referenced models, we have to run function separately to see the respective virtual blocks. I added this comment in the description itself now.
3. Yes, this automation creates unsaved changes for the model which we have executed. Added a warning message at the end and a note in the description.
A noble idea, but this doesn't appear to do what it's supposed to. I ran the function, and it highlighted every block in my model. It doesn't work across model reference boundaries. It creates unsaved changes since you temporarily change the startfcn.
- Used "RuntimeObject" to identify the virtual blocks instead of "add_exec_event_listener".
Updated the description.
Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.