Contenu principal

Simulink.SimulationData.Signal

R2026b

Container for logged signal information

Description

The software uses Simulink.SimulationData.Signal objects to store logged signal data and metadata. Simulink.SimulationData.Signal objects contain the logged data as well as information about the source block for the signal, including the port type and index.

Creation

Simulating a model that logs signals or outputs 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

The software creates Simulink.SimulationData.Signal objects when you log signals using signal logging, a Record block, a Scope block, or an Outport block.

The ThreeSigs model logs output data for three signals. Simulate the model.

mdl = "ThreeSigs";
out = sim(mdl);

The model is configured to log data using a single Simulink.SimulationOutput object named out. Inside the SimulationOutput object, the logged output data is grouped in a Simulink.SimulationData.Dataset object with the default logging name yout. Access the logged output.

out.yout
ans = 
Simulink.SimulationData.Dataset 'yout' with 3 elements

                         Name      BlockPath      
                         ________  ______________ 
    1  [1x1 Signal]      sineSig   ThreeSigs/Out1
    2  [1x1 Signal]      randSig   ThreeSigs/Out2
    3  [1x1 Signal]      chirpSig  ThreeSigs/Out3

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

To access a Signal object inside the output Dataset object, use braces to specify the signal index. For example, access the third logged signal.

sig3 = out.yout{3}
sig3 = 
  Simulink.SimulationData.Signal
  Package: Simulink.SimulationData

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


  Methods, Superclasses

To access a Signal object by name, use get. For example, access the signal named randSig.

mySig = get(out.yout,"randSig")
mySig = 
  Simulink.SimulationData.Signal
  Package: Simulink.SimulationData

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


  Methods, Superclasses

Version History

Introduced before R2006a