Add a List of Favorite Blocks to the Simulink Context Menu
Greg's Pick of the Week is Add Simulink Blocks from a given Model File with context menu by Paul.
While newer versions of Simulink have a feature that lists the most commonly used blocks in the context menu, this File Exchange entry allows you to explicitly define blocks that you want available from the context menu.
This File Exchange entry also provides a good example of how to customize the Simulink environment.
Contents
Add This Custom Menu to Your Simulink Installation
Once you have downloaded this File Exchange entry and unzip it, make sure that you:
>> sl_refresh_customizations
Now when you right-click on the Simulink canvas, there is a list of the blocks found in the custom_context_menu_blocks.mdl file.
How Is This Different Than "Most Frequently Used Blocks"?
Many of you may note that in more recent versions of Simulink, there is a list of the most frequently used blocks available in the context menu for the Simulink canvas.
The blocks listed here change depending which library blocks are used most often. The list that is created using Paul's method is static, and does not change based on usage. In addition the names that appear in Paul's list don't use the full library path name for the block.
How Does the Custom Menu Work?
Paul takes advantage of the Simulink customization feature "sl_customization.m" files.
The SL_CUSTOMIZATION file contains a definition of the customization, as well as the callback functions that might be executed as part of the customization.
These files can be used to:
- Customize Menus
- Customize views of the Simulink library browser
- Disable buttons and options in the model configuration parameters
- Hook into the C-code generation process in Simulink Coder
- Create custom checks for the Simulink Model Advisor
The sl_refresh_customizations command is used to register the SL_CUSTOMIZATION files with Simulink.
For more information on customizing Simulink and the SL_CUSTOMIZATION functions, check out Customizing the Simulink User Interface
Comments
If you would like to leave any comments regarding this post, please click here.
- Category:
- Picks
Comments
To leave a comment, please click here to sign in to your MathWorks Account or create a new one.