Guy on Simulink

Simulink & Model-Based Design

Creating Test Cases Using Signal Builder 16

Posted by admin,

Parasar KodatiBy 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!


Signal Builder Interface

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.

Creatign a Step signal using 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.

Excel file test case format

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

Signal Builder import from file

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.

Signal Builder import file dialog

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

zarah replied on : 1 of 16

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.

Raj replied on : 2 of 16

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.

Kenneth replied on : 4 of 16

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.

Sami replied on : 5 of 16

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.

Any idea?

Thanks
Sami

Aravindan replied on : 6 of 16

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 ?

reshma gh replied on : 8 of 16

hai
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

thank you

lakhan replied on : 9 of 16

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?

SimulinkUser replied on : 11 of 16

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 ?

Thank you.

Ram replied on : 12 of 16

Hi ,
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.

Keshav replied on : 13 of 16

Hi,

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?

Best regards,

Keshav Kumar

Guy Rouleau replied on : 14 of 16

@Keshav: You can use the function “[time, data] = signalbuilder(block)” to get the data, and then csvwrite to write the file.

Zulfqar replied on : 16 of 16

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

Add A Comment

Your email address will not be published. Required fields are marked *

*

Preview: hide