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.
16 CommentsOldest to Newest
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.
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?
@ Raj, It is possible to use the “signalbuilder” command to configure the signal builder programamtically:
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.
Thanks for the help.
after importing the time and data from Excel, ( more than 140 points, its really long like 10,000 data points) I can export the data to simulink, which I can see the whole list of data points, but signal generator only allows 132 seconds of data.
How do I export Signal builder signals to Excel sheet without any much scripting work !
[time, data, signames, groupnames] = signalbuilder(gcbh)
from the above command,we could access the time and datas, but it is not working for more than one signal, if we add two signal,we are getting two different time and datas, we need one time axis and two data axis. what will be the solution ?
any one answer it ?
How can I import from Signal builder the information about which signal is shown ?
i need to generate a single signal with increase in magnitude in y axis from 180-300, and time from 0-0.01, i need a signal to increase a step for every 0.002 seconds with increase in magnitude of 20 in y axis. i don’n need multiple signals i need a single signal with this requirement. help me
could anyone tell me how to create a staircase function which changes it’s value every 0.03 seconds(with time axis being from 0 to 0.12) and values are 60,70,85,80?
how can i import an excel data in to signal builder block using MATLAB R2008b
I am trying to add a Signal builder block to a simulink model programmatically using signalbuilder function.
Simulink model is loaded using load_system function.
Still i am able to see the simulink model getting opened whenever i try to add a signal builder block.
Could you please let me know if there is a way to hide the simulink model when a signal builder block is being added ?
When iam trying to import an excel which is containing 3 worksheets ,with the same signals and different values, i am not able to see that all the three groups of signal builder are updated with the 3worksheets.
only one group in signal builder is getting updated and remaining groups are as same as there is no update.
I’m trying to do the exactly opposite what you have explained in this article. Is it possible to save the signal builder data in a csv file?
@Keshav: You can use the function “[time, data] = signalbuilder(block)” to get the data, and then csvwrite to write the file.
If you are using R2015b or greater and have data in Excel, try the From Spreadsheet block. There is an example of using the From Spreadsheet block for model coverage in the Simulink documentation (https://www.mathworks.com/help/simulink/ug/power-window-example-case-study.html#bt9ms00).
i need to generate variable data to in signal builder from excel but when i import that data it shows this msg file …. format does not
comply with Signal Builder required format. plz tell me what can i do for that