File Exchange

image thumbnail

Highlight the Virtual Blocks

version 1.3 (11.1 KB) by

Highlights the virtual blocks that are optimized during simulation.

0 Downloads

Updated

View License

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.

Approach:
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.

Constraints:
- 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.

Comments and Ratings (4)

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.

Murali Mohan

Will Campbell

Will Campbell (view profile)

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.

Mosbah awajah

good

Updates

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.

1.1

Updated the description.

MATLAB Release
MATLAB 7.12 (R2011a)

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

» Watch video

hilite_virtual_blocks/