| Simulink® | ![]() |
| On this page… |
|---|
To cause your own top-level library (and its sublibraries) to appear in the Simulink® Library Browser:
Create a directory in the MATLAB® path for the top-level library and its sublibraries.
Each top-level library that you want to appear in the Library Browser must be stored in its own directory on the MATLAB path. In other words, two top-level libraries cannot exist in the same directory.
Create or copy the top-level library and its sublibraries into its directory.
The directory for each top-level library to be displayed in the Library Browser must contain a file named slblocks.m that describes the library. The easiest way for you to create such a file is to use an existing slblocks.m file as a template and edit it to describe your library. The next two steps direct you to perform this task.
Create a copy of the matlabroot/toolbox/simulink/blocks/slblocks.m file in the library's directory.
The file that you have copied is the slblocks.m file for the standard Simulink libraries.
Edit the file as necessary to specify the name, open function, mask, and structure of your library.
The comments in the slblocks.m file explain how to specify the information about your library that the Library Browser needs.
The following slblocks.m file describes a custom block library named "My Library."
function blkStruct = slblocks
%SLBLOCKS Defines a block library.
% Library's name. The name appears in the Library Browser's
% contents pane.
blkStruct.Name = ['My' sprintf('\n') 'Library'];
% The function that will be called when the user double-clicks on
% the library's name. ;
blkStruct.OpenFcn = 'mylib';
% The argument to be set as the Mask Display for the subsystem. You
% may comment this line out if no specific mask is desired.
% Example: blkStruct.MaskDisplay =
'plot([0:2*pi],sin([0:2*pi]));';
% No display for now.
% blkStruct.MaskDisplay = '';
% End of blocks
To find additional examples of slblocks.m files on your system, enter
which('slblocks.m', '-all')
at the MATLAB command prompt.
![]() | Creating Block Libraries | Working with Signals | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |