Main Content

Simulink.SampleTime Class

Namespace: Simulink
Superclasses:

Object containing sample time information

Description

The SampleTime class represents the sample time information associated with an individual sample time.

Use the methods Simulink.Block.getSampleTimes and Simulink.BlockDiagram.getSampleTimes to retrieve the values of the SampleTime properties for a block and for a block diagram, respectively.

Properties

Value

A two-element array of doubles that contains the period and offset of the sample time

Description

A 1xn character array that describes the sample time type

ColorRGBValue

A 1x3 array of doubles that contains the red, green and blue (RGB) values of the sample time color

Annotation

A 1xn character array that represents the annotation of a specific sample time (for example, 'D1')

OwnerBlock

For asynchronous and variable sample times, OwnerBlock is a character vector containing the full path to the block that controls the sample time. For all other types of sample times, it is an empty character vector.

ComponentSampleTimes

If the sample time is an async union or if the sample time is hybrid and the component sample times are available, then the array ComponentSampleTimes contains Simulink.SampleTime objects.

Copy Semantics

Value. To learn how value classes affect copy operations, see Copying Objects in the MATLAB® Programming Fundamentals documentation.

Examples

Retrieve the sample time information for the 'vdp' model.

ts = Simulink.BlockDiagram.getSampleTimes('vdp')

Simulink returns:

ts = 

  1x2 Simulink.SampleTime
  Package: Simulink

  Properties:
    Value
    Description
    ColorRGBValue
    Annotation
    OwnerBlock
    ComponentSampleTimes

  Methods

To examine the values of the properties:

ts(1), ts(2)

ans = 

  Simulink.SampleTime
  Package: Simulink

  Properties:
                   Value: [0 0]
             Description: 'Continuous'
           ColorRGBValue: [0 0 0]
              Annotation: 'Cont'
              OwnerBlock: []
    ComponentSampleTimes: {}

  Methods


ans = 

  Simulink.SampleTime
  Package: Simulink

  Properties:
                   Value: [Inf 0]
             Description: 'Constant'
           ColorRGBValue: [1 0.2600 0.8200]
              Annotation: 'Inf'
              OwnerBlock: []
    ComponentSampleTimes: {}

  Methods