View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Highlight the Virtual Blocks

5.0 | 1 rating Rate this file 5 Downloads (last 30 days) File Size: 11.1 KB File ID: #41272 Version: 1.3
image thumbnail

Highlight the Virtual Blocks



14 Apr 2013 (Updated )

Highlights the virtual blocks that are optimized during simulation.

| Watch this File

File Information

Syntax: hilite_virtual_blocks(<modelName>)
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.

Required Products Simulink
MATLAB release MATLAB 7.12 (R2011a)
Other requirements The tool is simple and it could work in most of the MATLAB versions.
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (4)
08 Jul 2013 Neelakanda Bharathiraja

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.

Comment only
03 Jul 2013 Murali Mohan

02 Jul 2013 Will Campbell

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.

Comment only
18 Apr 2013 Mosbah awajah


Comment only
15 Apr 2013 1.1

Updated the description.

08 Jul 2013 1.3

- Used "RuntimeObject" to identify the virtual blocks instead of "add_exec_event_listener".
- Added a warning note about the unsaved changes at the end of the run.

Contact us