MATLAB: How to create signals that have specific attributes in Simulink 7.4 (R2009b)

initializesimulinksimulink.signal

I would like to define the attributes (such as data type, dimension, sample time, etc) of the signals in the model. I would like to know if this is possible using any of the Simulink classes.

Best Answer

To assign and validate signal attributes in a model, use the Simulink.Signal class to define a signal object in the MATLAB workspace. This will allow you to define your signal with specific attributes. You can also use this signal object to initialize a signal in your model. To do this, follow these steps:
1) Define a Simulink.Signal object in the workspace:
mySig = Simulink.Signal
mySig.RTWInfo.StorageClass = 'ExportedGlobal' % Set its storage class to 'ExportedGlobal'
mySig.InitialValue = '10' % Set the signal's initial value
2) In your model, select a signal to validate against MySig object. Right click on a signal, choose signal properties and name the signal as mySig. Check the 'Signal name must resolve to Simulink.Signal object' option.
To learn more about Simulink.Signal objects, please refer to: