Customize Library Browser Appearance - MATLAB & Simulink (original) (raw)
Main Content
Reorder Libraries
The library name and sort priority determines its order in the tree view of the Library Browser. Libraries appear in ascending order of priority. Libraries that have the same priority are sorted alphabetically.
The SimulinkĀ® library has a sort priority of -1
by default. All other libraries have a sort priority of 0
by default. These sort priorities cause the Simulink library to display first in the Library Browser by default.
You can reorder libraries by changing their sort priorities. To change library sort priorities, add code in this form to an sl_customization.m
file on the MATLABĀ® path:
cm.LibraryBrowserCustomizer.applyOrder({'LIBNAME1',PRIORITY1, ... 'LIBNAME2',PRIORITY2, ... . . 'LIBNAMEN',PRIORITYN});
LIBNAMEn
is the name of the library (or its model file) andPRIORITYn
is an integer indicating the library sort priority. For example, this code moves the Simulink Extras library to the top of the Library Browser tree view.
cm.LibraryBrowserCustomizer.applyOrder({'Simulink Extras',-2});
After adding or modifying the sl_customization.m
file, entersl_refresh_customizations
at the MATLAB command prompt to see the customizations take effect.
For more information on the customization functions, see Register Customizations with Simulink.
Disable and Hide Libraries
To disable or hide libraries, sublibraries, or library blocks, insert code in this form in an sl_customization.m
file (see Register Customizations with Simulink) on the MATLAB path. Blocks that you disable or hide in a library also do not appear on the quick insert menu that you invoke in the model.
cm.LibraryBrowserCustomizer.applyFilter({'Item1','State', ... 'Item2','State', ... . . 'ItemN','State'});
ItemN
is the library, sublibrary, or block to disable or hide. Specify the item in the form'LibraryName/Sublibrary/Block'
.LibraryName
is the library name as it appears in the browser. For a custom library, you set this value in theslblocks.m
file with theBrowser.Name
property.Sublibrary
is the name of the sublibrary or, for a custom library, aSubsystem
block. You can specify a block inside the subsystem in your library or in a library that you open by way of the subsystemOpenFcn
callback. See Create Custom Library.Block
is the block name.
'State'
is'Disabled'
or'Hidden'
.
For example, this code hides the Sources
sublibrary of theSimulink
library and disables the Sinks
sublibrary.
cm.LibraryBrowserCustomizer.applyFilter({'Simulink/Sources','Hidden'}); cm.LibraryBrowserCustomizer.applyFilter({'Simulink/Sinks','Disabled'});
This code disables the Sqrt block in the sublibrary opened by way of theSubsystem2 block in the custom library 'My Library'
.
cm.LibraryBrowserCustomizer.applyFilter(... {'My Library/Subsystem2/Sqrt','Disabled'});
After adding or modifying the sl_customization.m
file, entersl_refresh_customizations
at the MATLAB command prompt to see the customizations take effect.
Expand or Collapse Library in Browser Tree
When you use the Library Browser in Standalone Mode, you can add a customization to expand or collapse any library in the Library Browser tree. For example, the Simulink
library is expanded by default. You can specify to instead collapse it by default. Add code in this form to yoursl_customization.m
file:
cm.LibraryBrowserCustomizer.applyNodePreference(... {'libraryName',logical});
Note
To open the Library Browser in standalone mode, in the Library Browser window, click the Launch standalone library browser button .
Use true
to expand the library and false
to collapse it.
For example, this code collapses the Simulink
library and expands theSimscape
library:
function sl_customization(cm) cm.LibraryBrowserCustomizer.applyNodePreference(... {'Simulink',false,'Simscape',true}); end
This code collapses a custom library named 'My Library'
.
function sl_customization(cm) cm.LibraryBrowserCustomizer.applyNodePreference(... {'My Library',false}); end
After adding or modifying the sl_customization.m
file, entersl_refresh_customizations
at the MATLAB command prompt to see the customizations take effect.