You can disable items that appear in the Simulink® Toolstrip and context menus. For context menus, you can also hide actions. To disable or hide an action, you must:
Get the name of the built-in action that you want to disable or hide.
Create or edit a customization file.
Create a filter function that disables or hides the item.
Register the filter function with the customization manager.
Refresh the Simulink customization file (
For example, this code creates and registers a filter function to disable the New Model button in the Simulink Toolstrip.
function sl_customization(cm) cm.addCustomFilterFcn('Simulink:NewModel',@myFilter); end function state = myFilter(callbackInfo) state = 'Disabled'; end
To get the name and icon for a built-in action from the Simulink Toolstrip, use the
In the MATLAB® Command Window, enter this command:
ans = logical 0
The command enables developer mode for the Simulink Toolstrip. The returned value indicates that developer mode was disabled before you entered the command.
Pause on an item in the Simulink Toolstrip and press Ctrl. On a Mac, press command (⌘) instead of Ctrl.
For example, pause on the Open button and press Ctrl.
Action: openModelAction Icon: open -------------------
The names of the corresponding action and icon appear in the MATLAB Command Window.
To register customizations, use a MATLAB function file named
sl_customization.m. Place the function on the MATLAB path of the Simulink installation that you want to customize or in the current folder.
You can have more than one
sl_customization.m file. The customizations in
each file take effect, with conflicts handled by each customization. For example, if you specify
priorities for libraries in multiple
sl_customization.m files, only one takes
effect. If you add the same menu item twice, it appears twice. To ensure that customizations
load as expected, refresh the customizations as described in Read and Refresh Customization Files.
sl_customization function accepts one argument: a handle to the customization manager object (
cm). For example:
sl_customization.m file, create a filter function. Your filter
function must accept a callback info object and return the state that you want to assign to
the item. Valid states are:
'Hidden' — Hide the item.
'Disabled' — Disable the item.
'Enabled' — Enable the item.
For example, this filter function assigns the
function state = myFilter(callbackInfo) state = 'Disabled'; end
Your filter function may have to compete with other filter functions and with Simulink to assign a state to an item. Which one succeeds depends on the strength of the state that each assigns to the item.
'Hidden' is the strongest state. If any filter function or
'Hidden' to a menu item, it is hidden. For
Simulink Toolstrip items, specifying
'Hidden' disables the
item instead of hiding it.
'Enabled', but is
itself overridden by
'Enabled' is the weakest state. For an item to be enabled, all
filter functions and the Simulink or Stateflow® products must assign
'Enabled' to the item.
Use the customization manager
addCustomFilterFcn method to register a
filter function. The
addCustomFilterFcn method takes two arguments: a tag
that identifies the menu or item to be filtered and a pointer to the filter function
For example, the following code registers a filter function for the New Model item on the Simulink Toolstrip.
function sl_customization(cm) cm.addCustomFilterFcn('Simulink:NewModel',@myFilter); end
sl_customization.m file is read when Simulink starts. If you change the
sl_customization.m file, either restart Simulink or enter this command to see the changes:
This command runs all
sl_customization.m files on the MATLAB path and in the current folder. Some side effects of running
Rebuilding the Simulink Toolstrip
Rebuilding all Simulink Editor menus
Rebuilding the Library Browser menus and toolbars
Clearing the Library Browser cache and refreshing the Library Browser
Reloading the Viewers and Generators Manager data