Main Content

Create Simulink Exercise Using MATLAB Course Designer

This example shows how to add a Simulink® exercise to a course in MATLAB® Course Designer™.

Simulink exercises contain tasks that teach concepts incrementally. Learners receive automated assessments and feedback after submitting their task solutions. For examples of Simulink exercises, see courses like Simulink Onramp.

Simulink Onramp exercise with tasks, a block diagram, and an assessment

For more information on MATLAB Course Designer, see Create Courses Using MATLAB Course Designer.

Create Course and Course Module

Before you can create a Simulink exercise, you must create a course that consists of one or more course modules. Each module is a collection of learning activities, such as Simulink exercises.

Access MATLAB Course Designer at course-designer.mathworks.com or through your learning management system (LMS).

To open MATLAB Course Designer from your LMS:

  1. Open MATLAB and Simulink Online™ Courses.

    For information on how to integrate MATLAB and Simulink Online Courses into your LMS, see Integrate MATLAB and Simulink Online Courses with Learning Management System (LMS).

  2. Click Launch Course Designer.

To create your self-paced online course:

  1. Click Create Course.

  2. Enter a course title.

  3. Click Create.

Create Course dialog box with a blank title box

To add a module to your course:

  1. Click Add Module.

  2. Enter a module title. Optionally, enter a description and estimated duration for the module. Then, click Add.

Add Module dialog box with blank title, description, and estimated duration boxes

Create Simulink Exercise

Each Simulink exercise consists of a starting model and one or more tasks.

To add a Simulink exercise to a course module:

  1. Expand the module in which you want to add the Simulink exercise.

  2. Select Add Learning Activity > Simulink Exercise.

  3. To start editing the exercise, next to the untitled Simulink exercise, click Edit.

Untitled Simulink exercise in a course module

While you edit the exercise, MATLAB Course Designer saves your changes automatically.

For example, these actions trigger an autosave:

  • Clicking outside an active text editor

  • Creating, uploading, copying, or deleting a file

  • Adding, updating, or deleting constants

  • Clicking outside an active Simulink Editor

  • Adding or removing assessment tests

While working on a part of the exercise, if you close the browser tab, go to another site in the same tab, or sign out, your recent changes might not be saved.

Add Exercise Title

The exercise title sets learner expectations for the exercise. A good title defines the scope of the learning activity, particularly in the context of the other learning activities in the same module.

For example, consider the Simulink exercise titles from the Simulink Graphical Environment module of Simulink Onramp.

Simulink Graphical Environment module with two exercises

  • Blocks and Parameters — This title suggests that the exercise teaches learners block and parameter basics. The exercise covers topics such as how to add blocks and set block parameter values.

  • Identifying Blocks and Signals — This title suggests that the exercise teaches learners how to identify blocks and signals. The exercise covers topics such as displaying hidden block names and specifying custom block and signal names.

To add a title:

  1. On the Edit Exercise Basics tab, in the left navigation pane, click Title.

  2. In the Exercise Title box, enter the title of your exercise.

Exercise Title box set to Identifying Blocks and Signals

Add Starting Model and Constants

Each Simulink exercise requires a starting model, which the learner edits to form their solution. You determine how much of the solution to provide in the starting model. Consider creating a starting model by uploading a model that you want the learner to create and then removing the elements that you want the learner to provide.

For example, a starting model can have a block diagram with two unconnected signal lines. As part of the exercise, you can ask learners to complete the block diagram.

Starting model with unconnected signal lines

To add a starting model:

  1. On the Edit Exercise Basics tab, in the left navigation pane, click Starting Model.

  2. Choose how to add the starting model.

    • New — Create a blank model.

    • Upload — Upload a model from your file system.

    • Copy From — Copy a solution from a task. (since R2026b)

The filename of the starting model appears under Starting Model.

Starting model file named StartingModel.slx

To modify the starting model:

  1. Next to the starting model filename, click Open.

  2. On the Starting Model tab, modify the starting model.

    • When you modify an uploaded model, your changes are saved to the exercise, not to the original model in your file system.

    • MATLAB Course Designer saves your changes automatically when you click outside the Simulink Editor or remain idle for an extended period of time.

    • Simulink exercises in MATLAB Course Designer use a simplified toolstrip that provides some common actions, such as specifying the simulation stop time, simulating the model, and viewing logged data. To access other actions, click the canvas and press Ctrl+Period (.). Then, search for an action.

Starting Model tab with the simplified toolstrip and a block diagram

Optionally, add constants that load into the MATLAB base workspace when learners start the exercise.

  1. On the Edit Exercise Basics tab, under Constants, click Add.

  2. Select the constants that you want to be available at the start of the exercise. Then, click Add. When you add constants, you save a snapshot that preserves their current values.

Constants table with b set to -25 and m set to 1200

You can modify the starting model and constants. For example, on the Edit Exercise Basics tab:

  • To replace the starting model, click New, Upload, or Copy From. Replacing the starting model permanently deletes the current starting model.

  • To save changes to constants, select the changed constants. Then, click Update.

  • To save more constants, click Add. In the dialog box that opens, select the constants to save. Then, click Add.

  • To remove constants, select the constants to remove. Then, click Delete.

  • To reload all constants, click Load to Workspace.

Customize Library Browser

To limit the blocks that learners can access in the Library Browser and quick insert menu, replace the default libraries with a custom library. A custom library lets you control the blocks that learners use as they develop their solutions.

For example, a custom library can include some source blocks for learners to use. For organization, the custom library can group blocks into different sublibraries by using Subsystem blocks.

Custom library with a Sources sublibrary that contains some source blocks, such as the Step block

When you add a custom library to an exercise:

  • The Library Browser provides learners with only the blocks in the custom library. When applicable, these blocks are nested in sublibraries.

    Library Browser with custom library

  • The quick insert menu provides learners with only the blocks in the custom library.

    Quick insert menu with custom library

The custom library should contain all blocks that learners must use to complete the exercise. Optionally, include other blocks, such as blocks that learners can use for further practice.

Regardless of whether you add a custom library for learners, you can still access all libraries that are available in MATLAB Course Designer.

To replace the default libraries with a custom library for learners:

  1. On the Edit Exercise Basics tab, in the left navigation pane, click Customized Library Browser.

  2. Choose how to add the custom library.

    • New — Create a blank library.

    • Upload — Upload a library from your file system.

Custom library file named CustomLibrary.slx

To modify a custom library:

  1. Next to the custom library filename, click Open.

  2. On the Custom Library tab, modify the custom library.

    • When you modify an uploaded library, your changes are saved to the exercise, not to the original library in your file system.

    • MATLAB Course Designer saves your changes automatically when you click outside the Simulink Editor or remain idle for an extended period of time.

    • Add blocks that support tasks and further practice. To add blocks, drag blocks from the Library Browser to the canvas or double-click the canvas and use the quick insert menu.

Custom Library tab with the simplified toolstrip and an assortment of source blocks

To replace the custom library, on the Edit Exercise Basics tab, click New or Upload. Replacing the custom library permanently deletes the current custom library.

To restore learner access to the default libraries, on the Edit Exercise Basics tab, next to the custom library filename, click the trash can button to the right of the Open button. This action removes and permanently deletes the current custom library.

Add Supporting Files

Supporting files that you add are on the MATLAB search path and are available throughout the exercise.

For example, suppose the starting model contains a masked block that uses a custom block icon. You can upload the image for the block icon as a supporting file.

To upload supporting files:

  1. On the Edit Exercise Basics tab, in the left navigation pane, click Supporting Files.

  2. Click Upload.

  3. Select a supporting file to upload. Then, click Open.

The filename of the supporting file appears.

Uploaded supporting file named block-mask-icon.png

To remove a supporting file, next to the filename, click the trash can button.

Create Task

A good task provides enough hands-on experience to teach a learning objective. To build learner confidence and reinforce prior skills, break exercises into small, focused tasks.

When you create an exercise, you also create its first task. To edit the task, in the task pane, click the task.

Task pane that contains the exercise title, Learner Preview button, Help button, Add Task button and entries for Exercise Basics and Task 1

To create additional tasks, in the task pane, click Add Task.

Add Task Background

The task background sets the context for the task. Use the task background to explain the learning objective and provide high-level information that learners need to know to be able to complete the task.

For example, the task background can describe what the starting model represents, the related equations, and what is missing.

Preview of task background

To add a background:

  1. On the Edit Task tab, in the left navigation pane, click Background.

  2. Author your content in the rich text editor. You can include formatted text, code, images, links, and equations.

Task background in rich text editor

To refresh the task preview, click outside the text editor.

Add Task Description

The task description provides the instructions you want the learner to follow to complete the task. Provide specific instructions, such as which blocks to add, which block ports to connect, and which parameter values to specify.

For example, the task description can instruct learners to add and connect blocks.

Preview of task description

To add a task description:

  1. On the Edit Task tab, in the left navigation pane, click Task.

  2. Author your content in the rich text editor. You can include formatted text, code, images, links, and equations.

Task description in rich text editor

To refresh the task preview, click outside the text editor.

Add Task Solution

The solution for a task in a Simulink exercise is a Simulink model that represents the correct answer for the task. To assess the learner's solution for a task, provide the correct solution. To provide further practice without an assessment, leave the solution empty.

For example, the solution for a block diagram with two unconnected signal lines can be a completed block diagram with those signal lines connected.

Solution with connected signal lines

To add a solution:

  1. On the Edit Task tab, in the left navigation pane, click Solution.

  2. Choose how to add the solution.

    • Copy From — Copy the starting model or a solution from another task.

    • New — Create a blank model.

    • Upload — Upload a model from your file system.

Solution file named SolutionModel.slx

To modify the solution:

  1. Next to the solution filename, click Open.

  2. On the Solution tab, modify the solution. If you copy the starting model or the model from the previous task, update the model in the same way that you expect learners to update it for this task.

    • When you modify an uploaded model, your changes are saved to the exercise, not to the original model in your file system.

    • MATLAB Course Designer saves your changes automatically when you click outside the Simulink Editor, add or remove assessment tests, or remain idle for an extended period of time.

    • Simulink exercises in MATLAB Course Designer use a simplified toolstrip that provides some common actions, such as specifying the simulation stop time, simulating the model, and viewing logged data. To access other actions, click the canvas and press Ctrl+Period (.). Then, search for an action.

Solution tab with block diagram

To let learners view the solution as they work on the task and after they submit their solution, on the Edit Task tab, select Enable learner to see solution.

To replace the current solution, on the Edit Task tab, click Copy From, New, or Upload. Replacing the solution permanently deletes the current solution.

To permanently remove the current solution, next to the filename, click the trash can button.

Add Task Assessment

The task assessment lets you evaluate the learner solution for correctness. In the assessment, you can test for block existence, correct signal data, and more.

Consider these best practices:

  • Include at least one test for each learner objective in the task.

  • If the task requires more than five tests, break it into multiple tasks.

  • Test only the elements that demonstrate an understanding of the concepts. You do not need to have a test for each block or signal the learner adds to the model for the task.

For example, the assessment can test whether the learner solution captures the same data that you capture for a signal. When the learner works on this task, the test appears in the Assessment pane.

Signal data test

After the learner submits their solution, the test returns a pass or fail result. If the learner's solution fails the test, the learner can try again.

Signal data test pass

To add tests for your assessment:

  1. Add a solution if you have not already done so. To add a solution, see Add Task Solution.

  2. If the solution is open, click the Solution tab. Otherwise, on the Edit Task tab, in the left navigation pane, click Solution. Then, next to the solution filename, click Open.

  3. In the Assessment pane of your solution, click Add Test and select an option from the list.

For example, to test that the learner solution captures the same data that you capture for a signal named velocity:

  1. Select Add Test > Signal data.

  2. In the model, connect the velocity signal to the new Signal Assessment block.

  3. Click Capture Signal Data.

  4. Check that the Signal source value and captured signal data match your expectations.

Solution with signal data test and captured signal data window

For more information about the tests you can create in MATLAB Course Designer, see Simulink Exercise Assessment Tests in MATLAB Course Designer.

Add Task Hint

To help the learner complete the task, provide a hint. A good hint can include additional reference material, address common mistakes, and remind learners of important details such as block names. For example, if the task is to add a block, the hint can explain how to add a block.

When the learner works on a task, the hint is hidden until they click the Hint hyperlink.

Expanded hint

To add a task hint:

  1. On the Edit Task tab, in the left navigation pane, click Hint.

  2. Author your content in the rich text editor. You can include formatted text, code, images, links, and equations.

Hint in rich text editor

Preview Task

A learner preview lets you check the functionality and solutions of the tasks you create.

To preview a task from the learner perspective:

  1. Check that the exercise has a starting model.

  2. If the exercise has more than one task and you want to preview the tasks out of order, check that the previous task has a complete solution. For example, to preview task 2, check that task 1 has a solution. Each task builds on the solution of the previous task.

  3. In the task pane, click Learner Preview. Then, select whether to preview the exercise from the beginning or from a specific task.

  4. Complete the task as if you are the learner.

Learner preview of task 1

To close the learner preview, at the top left, click Return to Editing.

Next Steps

To add more tasks to the Simulink exercise, in the task pane, click Add Task.

To reorder tasks, in the task pane, use the Move Task Up and Move Task Down buttons.

To add additional modules and learning activities to your course, see Create Courses Using MATLAB Course Designer.

After your course is ready, click Publish. Then, you can assign your course to learners from your learning management system. For more information on how to assign courses, see Add MATLAB and Simulink Online Courses to LMS Course.

See Also

Topics