Guy and Seth on Simulink
January 12th, 2011
Creating Test Cases Using Signal Builder
By Parasar Kodati
Every model needs to be tested, and all tests need inputs. For example control algorithms are typically tested with step or ramp inputs. An automotive suspension model test inputs may include road profiles and driver actions.
In Simulink, the Signal Builder block allows you to incorporate test cases as a signal source in your model. Using the Signal Builder block you can:
- Graphically create and tweak signals using the signal builder interface
- Manage groups of input signals, each corresponding to a simulation run
- Run multiple simulations driven by different signal data sets
- Starting in R2010b directly import signal data from files into the signal builder!

The above snapshot shows the part of Signal builder with different groups of signals from an automotive demo (type sf_car in your MATLAB installation to open this demo). In this case the different groups have the brake and throttle signals for different driving conditions. The gear shift logic modeled in Stateflow is fed with these test cases to see if the gear shifting is as expected.
Creating and importing test case signals
The easiest way to create a test case signal is to use one of the several built-in signals as the starting point and then modify it further to exactly represent the test conditions. Note that using the Custom option you can also use a MATLAB variable to bring in signal data into the Signal Builder.

Starting in R2010b you can directly import test cases from Excel or MAT files. Here I have some road profile data in an Excel sheet. To create multiple signal groups in the signal builder, the different test cases need to be in separate sheets as shown in the figure below.

To import this test case data into Signal Builder, select the “Import from File” option in the File menu.

In the Import dialog, select the signals and groups to be imported and how they will be placed in the Signal Builder interface. The Status History pane of the Import Dialog should help you configuring the import properly.

Now it's your turn!
How do you manage test cases in Simulink? Leave a comment here and tell me about it.
17:30 UTC |
Posted in Model-Based Design, Signals |
Permalink |
4 Comments »
You can follow any responses to this entry through the RSS 2.0 feed.
You can skip to the end and leave a response. Pinging is currently not allowed.
Leave a Reply
|
Hi!
thanks for your help, but i dont need to generate different kind of inputs, I am simulating an active filter, but I dont get good response from the control part( am using pq theory). My problem is the signals from outport blocks do not reach the inport blocks connected to my subsystem, hence I dont get any signal at all out of the subsystem.
Hi,
Thanks for the valuable information shared about importing data into signal builder.
Is there any way by which we can import a .mat file into the Signal-Builder using M-script only?
Regards,
R.S.
@ Raj, It is possible to use the “signalbuilder” command to configure the signal builder programamtically:
http://www.mathworks.com/access/helpdesk/help/toolbox/simulink/slref/signalbuilder_cmd.html
Note that you will need to first load the MAT-file into the MATLAB workspace and then use the command above to specify how this data should be used in the signal builder.
F1 = 1.09 + 0.199 *a – 0.0266 *X – 0.400 *a.^2 – 0.316 *X.^2 + 0.131* a*X
Please can anyone help me on how I can generate a 3D plot using the expression above.
Many thanks.