Main Content

Create a Blockset Project

A blockset is a collection of blocks organized in Simulink® libraries for a purpose. The blocks could be part of a standalone library or may be part of an extensive project.

The Blockset Designer is a Projects-based tool that allows you to create, group and manage custom blocks. After creating different blocks, you can add tests, document your blocks, and run Model Advisor checks. If your model contains any S-function or S-function Builder blocks, you can build them using the interface. In addition, you can import your existing blocksets, and set up a Blockset Designer project. You can create new Subsystem, MATLAB System, S-function, and S-function Builder blocks using the Blockset Designer.

Create a New Blockset Project

  1. Open the Simulink start page, and pause on Blockset Designer, and click Create Project.

  2. Specify a name for your project. Note that when you start typing a name for your project, a new folder is automatically created for you in the directory username\MATLAB\Projects\<foldername>. If you would like to specify an existing project folder, click the Browse button.

    If you create a new folder, click OK to create a new project folder. Confirm this action by clicking Yes.

  3. Now you are directed to the Blockset Designer project user interface. You are looking at the project at the blockset level. In a Blockset Designer project, the icon represents the blockset you are working on.

    The Blockset Designer consists of these components at the blockset level:

    1 — The Views panel shows the project file views and the interface of the Blockset Designer. To view all files in the project root, click Files, and then the All tab. To only see the files in the project, click Project.

    2 — The Blockset Tree panel shows the organization of the blocks and sublibraries in the project. When you add a new block or a new sublibrary to your blockset, it will show up in this tree. You can also use this tree to switch between the sublibrary and block control menus.

    3 — The Top Library corresponds to the Browser.Library in the library information file slblocks.m, which is the entry point to the blockset. Click Open to display the location of the top library. Click Browse to change the top library for the blockset. Note that if you change the top library, slblocks.m updates accordingly, and your blockset project is reloaded based on the new top library. See Add Libraries to the Library Browser to learn more about slblocks.m

    4 — The status table shows the status of the blocks and their artifacts. For more information on the status table, see Create and Organize Block Artifacts.

Add a New Sublibrary

Start building your blockset project by adding a sublibrary. Sublibraries enable you to organize and manage your blocks. In your blockset project, the icon represents the sublibraries. You can add a new sublibrary to your blockset using in these ways:

  1. From the toolstrip, select the Sublibrary button.

  2. Click the blockset from the blockset tree, and from the context menu, select Sublibrary.

  3. Name your sublibrary and close the window. After creating sublibraries, click one of them and see the changes in the working area. Observe that on the top right of the working area, you see Sublibrary instead of the Top Library and the Help Page.

  4. Click Open on the right to open the library model constructed from your sublibrary. This library model contains all blocks from the selected sublibrary.

Add a New Block

Blockset Designer supports many custom blocks.

  • You can add a new block to your blockset project from the ADD menu on the toolstrip

  • Alternatively, when you select the blockset or the sublibrary, open the context menu and click Add Block.

You can create these blocks in the Blockset Designer:

  • C MEX S-function blocks in basic, discrete, continuous templates. You can also create a C MEX S-function from an existing example.

  • Subsystem block

  • MATLAB System block with basic, advanced, and Simulink Extension System object™ templates.

  • S-functions created using the S-function Builder.

The working area changes according to the blocks added to your project. For a Subsystem block, you see block properties such as the block path and type, Test, and Documentation in the working area.

When you click a MATLAB System block from the blockset tree, you can edit the System object code and add Test using the working area. To add documentation for a MATLAB System block, add comments in the System object code, and they are automatically added to block documentation for you.

If you have an S-function or a S-function Builder block in your blockset project, you can monitor the block properties, build and edit your S-function code, build the script, add test and document to your block.

Note that when you add an S-function to your Blockset Designer project, you need to write the code for your S-function and build it before adding test. To learn more about how to build S-functions using the Blockset Designer, see S-Function Related Artifacts.

Besides the blocks mentioned above, you can add and customize other available Simulink library blocks in the project, but you cannot do any operations such as adding test or documentation.

When you are finished creating your project, you can add:

  • Test, or a test suite for your blocks.

  • Documentation for your sublibraries and/or for your blocks.

See Create and Organize Block Artifacts for more information.

Create a Project from an Existing Blockset

Using the Blockset Designer, you can organize blocks, and add tests and documentation to your blocks and blockset. To import your blockset and create a new Blockset Designer project:

  1. Open the Simulink Start Page. Under Simulink select Blockset Designer, and click Create Project

  2. In the New Project dialog box, enter a project name, browse to select the folder containing your files, and click OK.

  3. In the Welcome to your project dialog box, click Set Up Project to continue.

  4. In the Set Up Project (Step 1 of 3) dialog box, choose folders to add to the project path. When you open the project, these folders are added to your MATLAB® search path, and removed when you close the project. Add project folders and subfolders to the project path to ensure that you have access to slblocks.m and related libraries. slblocks.m contains all information about the top library in your project. To learn more, see Add Libraries to the Library Browser. To add all project folders, select Add with Subfolders and then the project folder containing all your subfolders. Click Next.

  5. In the Set Up Project (Step 2 of 3) dialog box, optionally specify startup and shutdown files.

    • Use startup files to configure settings when you open the project. Startup files automatically run (.m and .p files), load (.mat files), or open (Simulink models) when you open the project.

    • Use shutdown files to specify MATLAB code to run as the project shuts down. You do not need to use shutdown files to close models when you close a project, because it automatically closes any project models that are open, unless they are dirty. The project prompts you to save or discard changes.

    Click Add to specify startup or shutdown files.

  6. In the Set Up Project (Step 3 of 3) dialog box, specify a slblocks.m library information file for this blockset. This file contains information on your blockset settings, and the location of your top library. Without this file, your project cannot be set up properly. Click Browse to select the file.

  7. Click Finish and a new project opens. The Blockset Designer automatically adds all your files to the project. During the import process, based on the top library, the Blockset Designer explores the hierarchy of the blockset, creates dedicated folders for each type of supported blocks, and adds the folders to project and search corresponding artifacts such as S-function MEX file, source files, and System object files for MATLAB System block automatically. See Blockset Project File Structure for more information.

Now you can start adding more blocks to your project, or add test or documentation to your existing blocks in the project. To learn more about how to build, test and document your blocks, see Create and Organize Block Artifacts.

Blockset Project File Structure

When you create a blockset project, either by creating a new blockset or importing an existing blockset, the Blockset Designer organizes your project in a certain file organization. This organization changes with the different type of blocks you have in your project. Use this table as a guide to determine which folders are created for each block. To see your blockset folder structure, click Files in the Views panel.

Block TypeFolder NameFolder Contains
Subsystemdoc

Documentation source and html file for the documentation

library

Library model for the block

unittest

Unit test model, test suite, and input file for the test

MATLAB Systemlibrary

Library model for the block

sysobj

The System object code for the MATLAB System block

unittest

Unit test model, test suite, and input file for the test

S-function and S-function Builder

buildS-function build script
doc

Documentation source and HTML file for the documentation

library

Library model for the block

mex

S-function MEX and code generation files

srcS-function source files
unittest

Unit test model, test suite, and input file for the test

Blockset Project (common)doc

Documentation source and HTML file for the documentation

library

Library model for the block

script

blocksetroot.m file to return the blockset root folder

See Also

| | |

Related Topics