In this article, we’ll see what a Simulink Signal Builder is and review the main things you need to know if you’re going to use them, such as how to:

  • Add a point to a signal
  • Add and delete signals from a Signal Builder
  • Name the output signals
  • Add a signal with a specific shape
  • Set up the simulation time for your Signal Builder
  • Use different tests in a Signal Builder

What Is a Simulink Signal Builder

Signal builders are used for creating tests in Simulink. Let’s say you’ve created a low-pass filter and want to make sure that you didn’t make any mistakes while developing it. You may want to input a signal to your low-pass filter such as different kind of sine waves with different frequencies and look at your filter’s behavior.

A Signal Builder also allows you to construct different kinds of test cases so that you are running all of them to study your model’s behavior.

You can find Simulink blocks in the Simulink library at “Simulink/Sources.”  Here’s what the Signal Builder block looks like:

signal builder simulink block

Here is what it looks like when you double-click on it:

signal builder editor default view

How to Use a Signal Builder in MATLAB & Simulink

Add a Point to a Signal in a Signal Builder

As you can see, by default you have what is called “pulse signal.” If you click on the “Start simulation” icon inside the Signal Builder, you will run the simulation with this signal as an output of the signal builder.

You can modify the signal by clicking on one line or one point and moving it around. As you can see, this only modifies the location of the straight lines delimited by points or the location of the points. The issue is that there are only six points on this signal, so how do you add points?

To do that, you need to:

  1. Hold the shift key
  2. Click on the desired location of the point on the signal

This allows you to create the signal shape that you desire in order to test your model:

signal builder add point simulink tutorial

Add, Delete, and Name an Output Signal in a Signal Builder

  • Add a signal: if you want to add a new signal output because your model requires more than one signal, click on one of the three icons at the top of your Signal Builder. Using these icons, you have three choices: a “constant signal,” a “step signal,” and a “pulse signal.” Here’s what those icons look like:
    add signal to signal builderObviously, the icons are shortcuts, not the whole thing. If you want to add a new signal that is outside of these options, such as a sinewave with a specific frequency, you can click on “Signal > New > Sampled Sin…” Then, set the frequency, amplitude, offset, and samples per period of your sinewave and click “OK:”sinewave example for signal builder
  • Delete a signal: if you’ve added a signal but you want to delete it from the Signal Builder:
    1. Click on the desired signal.
    2. Press the delete key.
  • Name a signal: Name your output signal by clicking first on the signal and then using the “Name” field at the bottom left of your Signal Builder:
    change the name of your output signalThis allows you to see the name from your model perspective. For example, if you call your first output “myNewSignal,” then it will be visible from your Simulink model:signal builder seen from your simulink model with a new signal name

Change the Simulation Duration of a Signal Builder

You may also want to modify the simulation time of your signal builder so that you can shape your signal after more than 10 seconds from the start of your simulation. You can do that by going to Axes > Change Time Range… and setting a higher value for the “Max time” field:

set up simulation time displayed

Signal Builders and Tests

Add a Test Case to a Signal Builder

  • Regression testing: In a signal builder, you can add different test cases, that allow for regression testing of your model. That means that if you create a few test cases for your model, you can run all of them and compare the outputs to a previous version. This is to make sure that if you fix a bug, you don’t modify your model’s behavior in unhelpful ways.
  • Testing throughout implementation: If you modify your model, you can also make sure that the modification altered your model’s behavior in the way you wanted. Let’s say that you have a satellite model with different modes (e.g. idle mode, safe mode) that are activated when certain conditions are met. To ensure that it will work the way you want if you modify the activation conditions of those modes you may want to create a test case that corresponds to the activation/deactivation of those conditions.

So, to add a test case to a Signal Builder:

  1. Click on the gear at the top right of your Signal Builder.
  2. Click Copy.

Run a Specific Test Case

If you want to run a specific test case:

  1. Select it by using the drop-down menu
  2. Click the run icon in your signal builder.

Run All of the Test Cases of Your Signal Builder

You can also run every test case of your model at once. This can be useful if you want to compare your model against an earlier version by observing the differences of behavior between those models for the same set of test cases.

It is also very useful if you want to improve the coverage of your model because if you add test cases,  the model coverage will improve provided that the additional tests are activating parts of the model that the existing ones didn’t.

To run all test cases, you can click “Run all and produce coverage” at the top of your Signal Builder:

run test for all scenarios

Key takeaways:

  1. The signal builder block in Simulink allows you to test your model.
  2. You can add a point to a Signal Builder by:
    1. Holding shift.
    2. Clicking the desired location on your signal.
  3. Add  a signal by using the icons:add signal to signal builder
  4. Delete a signal by:
    1. Clicking on it.
    2. Pressing the delete key.
  5. Name an output signal using the “Name” field at the bottom left of your Signal Builder.
  6. You can add test cases to a Signal Builder by clicking on:
    1. The gear at the top right of your Signal Builder.
    2. Copy.”
  7. You can run a specific test case of your signal builder by:
    1. Choosing it in the drop-down menu.
    2. Clicking the “Start simulation” icon.
  8. Run every test case by click on “Run all and produce coverage” at the top of the Signal Builder.

For more information, you can refer to the MathWorks documentation about the Signal Builder block: