Main Content

Simulink.SimulationData.Signal

Container for signal logging information

Description

The software uses Simulink.SimulationData.Signal objects to store signal logging information during simulation. Simulink.SimulationData.Signal objects contain information about the source block for the signal, including the port type and index.

Creation

Simulating a model that has signals marked for logging creates one or more Simulink.SimulationData.Signal objects.

Description

sigobj = Simulink.SimulationData.Signal creates an empty Simulink.SimulationData.Signal object. Use this syntax to manually create a Signal object that contains external input data to load using Inport or In Bus Element blocks.

example

Properties

expand all

Block path of source block for Signal object, specified as a Simulink.SimulationData.BlockPath object.

Name of Signal object to use for name-based access, specified as a string or character vector.

Propagated name of Signal object, specified as a string or character vector.

Signal logging captures the propagated signal name if the logging format is Dataset and you:

  • Mark the signal for signal logging.

  • Enable Configuration Parameters > Data Import/Export > Signal logging.

  • Select Show Propagated Signals in the Signal Properties dialog box.

The propagated signal name does not include angle brackets (<>).

For more information, see Signal Label Propagation.

Port index of logged signal, specified as a positive integer.

Type of port, specified as 'outport' or 'inport'.

  • When you log data using signal logging, the port type is 'outport'.

  • When you create a Signal object to use as input to a model, the port type is 'inport'.

Logged time and data, specified as:

  • A MATLAB® timeseries object

  • A MATLAB timetable object

  • A structure of MATLAB timeseries objects (for bus signals)

  • A structure of MATLAB timetable objects (for bus signals)

  • An array of structures of MATLAB timeseries objects (for array of buses signals)

  • An array of structures of MATLAB timetable objects (for array of buses signals)

  • An array of MATLAB timeseries objects (for nonbus signals in a For Each subsystem)

  • A cell array of MATLAB timetable objects (for nonbus signals in a For Each subsystem)

For an example of how to use the Values property and plot logged signal data, see Logging Intervals.

Examples

collapse all

Create a Simulink.SimulationData.Signal object. Specify the signal name and data values.

Time = 0.1*(0:99)';

sig = Simulink.SimulationData.Signal;
sig.Name = "Sine";
sig.Values = timeseries(sin(Time),Time)
sig = 

  Simulink.SimulationData.Signal
  Package: Simulink.SimulationData

  Properties:
              Name: 'Sine'
    PropagatedName: ''
         BlockPath: [1×1 Simulink.SimulationData.BlockPath]
          PortType: 'inport'
         PortIndex: 1
            Values: [1×1 timeseries]


  Methods, Superclasses

When you simulate a model with signals marked for logging, the software saves signal logging information in one or more Simulink.SimulationData.Signal objects.

Open the model sldemo_fuelsys that has several signals marked for logging. Then, simulate the model.

mdl = "sldemo_fuelsys";
open_system(mdl)
sim(mdl);

The logged simulation data is grouped in a Simulink.SimulationData.Dataset object named sldemo_fuelsys_output.

sldemo_fuelsys_output
sldemo_fuelsys_output = 
Simulink.SimulationData.Dataset 'sldemo_fuelsys_output' with 10 elements

                         Name            BlockPath                                
                         ______________  ________________________________________ 
    1  [1x1 Signal]      ''              sldemo_fuelsys/EGO Fault Switch         
    2  [1x1 Signal]      air_fuel_ratio  sldemo_fuelsys/Engine Gas Dynamics      
    3  [1x1 Signal]      ''              sldemo_fuelsys/Engine Speed Fault Switch
    4  [1x1 Signal]      speed           sldemo_fuelsys/Engine_Speed_Selector    
    5  [1x1 Signal]      ''              sldemo_fuelsys/MAP Fault Switch         
    6  [1x1 Signal]      map             sldemo_fuelsys/MAP_Selector             
    7  [1x1 Signal]      ego             sldemo_fuelsys/O2_Voltage_Selector      
    8  [1x1 Signal]      ''              ...o_fuelsys/Throttle Angle Fault Switch
    9  [1x1 Signal]      throttle        sldemo_fuelsys/Throttle_Angle_Selector  
   10  [1x1 Signal]      fuel            sldemo_fuelsys/To Plant                 

  - Use braces { } to access, modify, or add elements using index.

Access the Signal object named speed.

get(sldemo_fuelsys_output,"speed")
ans = 
  Simulink.SimulationData.Signal
  Package: Simulink.SimulationData

  Properties:
              Name: 'speed'
    PropagatedName: ''
         BlockPath: [1x1 Simulink.SimulationData.BlockPath]
          PortType: 'outport'
         PortIndex: 1
            Values: [1x1 timeseries]

Version History

Introduced before R2006a