1

I have a SIMULINK model that uses bus inputs and outputs as top level ports. When I am testing it, I don't know how to create a test signal as a bus and feed it into the model. I know that the straightforward way to do it is to create lots of individual signal and use bus creator block to group those as a bus that will feed into the model. However, this may not be a very efficient way to do things. Does anyone know any alternative?

I tried to look into Mathworks website but nothing really came up. Any help would be appreciated.

ha9u63a7
  • 6,233
  • 16
  • 73
  • 108

2 Answers2

2

You need to define the data using Timeseries objects. See Import Structure of timeseries Objects for Buses

for an example.

Phil Goddard
  • 10,571
  • 1
  • 16
  • 28
  • Thanks for this! I just wanted to point it out that this solution probably doesn't work for legacy versions (before R2012 or R2011) as Mathworks didn't have those necessary classdefs. – ha9u63a7 Dec 04 '13 at 07:51
2

If your test signal is constant the easiest way is to add a Simulink Constant block and define the variable as a structure in some script .m file:

testSignal.a = 10;
testSignal.b = 20;
etc

Double-click on the Constant block, add the variable and then switch to the Signal Attributes tab where you specify the data type to match your bus signal definition.

remus
  • 2,635
  • 2
  • 21
  • 46