Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
slref.pdf
Скачиваний:
39
Добавлен:
26.03.2015
Размер:
16.01 Mб
Скачать

7

Simulink Classes

eventData

Provide information about block

 

method execution events

getDescription

Extract file description without

 

loading block diagram into memory

getMetadata

Extract file metadata without

 

loading block diagram into memory

Simulink.AliasType

Create alias for signal and/or

 

parameter data type

Simulink.Annotation

Specify properties of model

 

annotation

Simulink.BlockCompDworkData

Provide postcompilation information

 

about block’s DWork vector

Simulink.BlockCompInputPortData

Provide postcompilation information

 

about block input port

Simulink.BlockCompOutputPortData

Provide postcompilation information

 

about block output port

Simulink.BlockData

Provide run-time information about

 

block-related data, such as block

 

parameters

Simulink.BlockPath

 

Simulink.BlockPortData

Describe block input or output port

Simulink.BlockPreCompInputPortDataProvide precompilation information about block input port

Simulink.BlockPreCompOutputPortDataProvide precompilation information about block output port

7 Simulink Classes

Simulink.Bus

Specify properties of signal bus

Simulink.BusElement

Describe element of signal bus

Simulink.ConfigSet

Access model configuration set

Simulink.ConfigSetRef

Link model to configuration set

 

stored independently of any model

Simulink.GlobalDataTransfer

Configure concurrent execution data

 

transfers

Simulink.Mask

Control masks programmatically

Simulink.MaskParameter

Manipulate mask parameters

 

programmatically

Simulink.MDLInfo

Extract model file information

 

without loading block diagram into

 

memory

Simulink.ModelAdvisor

Run Model Advisor from MATLAB

 

file

Simulink.ModelDataLogs

Container for model’s signal data

 

logs

Simulink.ModelManagement.Project.CurrentProjManipulatectthe currently open Simulink project from the command line

Simulink.ModelWorkspace

Describe model workspace

Simulink.MSFcnRunTimeBlock

Get run-time information about

 

Level-2 MATLAB S-function block

Simulink.NumericType

Specify data type

Simulink.ParamCoderInfo

Specify information needed to

 

generate code for parameter

Simulink.Parameter

Specify value, value range, data

 

type, and other properties of block

 

parameter

7-2

Simulink.RunTimeBlock

Allow Level-2 MATLAB S-function

 

and other MATLAB programs to

 

get information about block while

 

simulation is running

Simulink.SampleTime

Object containing sample time

 

information

Simulink.ScopeDataLogs

Store data logged by Scope signal

 

viewer

Simulink.sdi.DiffRunResult

Results from comparing two

 

simulation runs

Simulink.sdi.DiffSignalResult

Results from comparing two signals

Simulink.sdi.Run

Manages signal data and metadata

 

of simulation run

Simulink.sdi.Signal

Manages signal time series data and

 

metadata

Simulink.Signal

Specify attributes of signal

Simulink.SignalCoderInfo

Specify information needed to

 

generate code for signal

Simulink.SimState.ModelSimState

Access SimState snapshot data

Simulink.SimulationData.BlockPath

Fully specified Simulink block path

Simulink.SimulationData.Dataset

Container for logged data using

 

MATLAB timeseries objects

Simulink.SimulationData.DataStoreMemory Simulink.SimulationData.LoggingInfo Signal logging override settings

Simulink.SimulationData.ModelLoggingInfoSignal logging override settings for a model

Simulink.SimulationData.Signal

Simulink.SimulationData.SignalLoggingISignalfo logging override settings for signal

Simulink.SimulationOutput

Access object values of simulation

 

results

7-3

7 Simulink Classes

Simulink.SoftwareTarget.AperiodicTriggerDescribe aperiodic trigger Simulink.SoftwareTarget.PeriodicTriggerDescribe periodic trigger

Simulink.SoftwareTarget.PosixSignalHandlerDescribe aperiodic trigger for POSIX targets

Simulink.SoftwareTarget.Task

Describe task that models unit of

 

concurrent execution

Simulink.SoftwareTarget.TaskConfigurationConfigure model for concurrent

 

execution

Simulink.SoftwareTarget.Trigger

Base class for PeriodicTrigger and

 

AperiodicTrigger

Simulink.SoftwareTarget.WindowsEventHandlerDescribe aperiodic trigger for

 

Windows® targets

Simulink.SubsysDataLogs

Container for subsystem’s signal

 

data logs

Simulink.TimeInfo

Provide information about time data

 

in Simulink.Timeseries object

Simulink.Timeseries

Store data for any signal except mux

 

or bus signal

Simulink.TsArray

Store data for mux or bus signal

Simulink.VariableUsage

Get information about workspace

 

variables and blocks that use them

Simulink.Variant

Specify a model reference variant

 

and its execution environment

Simulink.WorkspaceVar

Contains information about

 

workspace variables and blocks that

 

use them

7-4

eventData

Purpose

Description

Parent

Children

Property

Summary

Properties

Provide information about block method execution events

Simulink software creates an instance of this class when a block method execution event occurs during simulation and passes it to any listeners registered for the event (see add_exec_event_listener). The instance specifies the type of event that occurred and the block whose method execution triggered the event. See “Access Block Data During Simulation” for more information.

None

None

 

Name

Description

 

 

“Type”

Type of method execution event that occurred.

 

 

“Source”

Block that triggered the event.

 

 

 

 

 

Type

Description

Type of method execution event that occurred. Possible values are:

 

event

Occurs...

 

 

'PreOutputs'

Before a block’s Outputs method executes.

 

 

'PostOutputs'

After a block’s Outputs method executes.

 

 

'PreUpdate'

Before a block’s Update method executes.

 

 

'PostUpdate'

After a block’s Update method executes.

 

 

'PreDerivatives'

Before a block’s Derivatives method executes.

 

 

'PostDerivatives'

After a block’s Derivatives method executes.

 

 

Data Type

 

 

 

string

 

 

7-5

eventData

Access

RO

Source

Description

Block that triggered the event

Data Type

Simulink.RunTimeBlock

Access

RO

7-6

Simulink.AliasType

Purpose

Create alias for signal and/or parameter data type

Description This class allows you to designate MATLAB variables as aliases for signal and parameter data types. You do this by creating instances of this class and assigning them to variables in the MATLAB or model workspaces (see “Creating a Data Type Alias” on page 7-7). The MATLAB variable to which a Simulink.AliasType object is assigned is called a data type alias. The data type to which an alias refers is called its base type. Simulink software allows you to set the BaseType property of the object that the variable references, thereby designating the data type for which it is an alias.

Simulink software lets you use aliases instead of actual type names in dialog boxes and set_param commands to specify the data types of Simulink block outputs and parameters. Using aliases to specify signal and parameter data types can greatly simplify global changes to the signal and parameter data types that a model specifies. In particular,

changing the data type of all signals and parameters whose data type is specified by an alias requires only changing the base type of the alias. By contrast, changing the data types of signals and parameters whose data types are specified by an actual type name requires respecifying the data type of each signal and parameter individually.

Note Suppose you specify an instance of the Simulink.AliasType class as the value of a Simulink.Parameter object’s Data type property. If you enter the parameter object in a subsystem’s mask, the subsystem displays the data type’s base type instead of its alias name.

Creating a Data Type Alias

You can use either the Model explorer or MATLAB commands (see “MATLAB Commands for Creating Data Type Aliases” on page 7-8) to create a data type alias.

To use the Model explorer to create an alias:

7-7

Simulink.AliasType

1Select Base Workspace (i.e., the MATLAB workspace) in the Model explorer’s Model Hierarchy pane.

You must create data type aliases in the MATLAB workspace. If you attempt to create an alias in a model workspace, Simulink software displays an error.

2Select Simulink.AliasType from the Model explorer’s Add menu.

Simulink software creates an instance of a Simulink.AliasType object and assigns it to a variable named Alias in the MATLAB workspace.

3Rename the variable to a more appropriate name, for example, a name that reflects its intended usage.

To change the name, edit the name displayed in the Name field in the Model explorer’s Contents pane.

4Enter the name of the data type that this alias represents in the Base type field in the Model explorer’s Dialog pane.

You can specify the name of any existing standard or user-defined data type in this field. Skip this step if the desired base type is double (the default).

5Use the MATLAB save command to save the newly created alias in a MAT-file that can be loaded by the models in which it is used.

MATLAB Commands for Creating Data Type Aliases

Use the following syntax to create a data type alias at the MATLAB command line or in a MATLAB program

ALIAS = Simulink.AliasType;

where ALIAS is the name of the variable that you want to serve as the alias. For example, the following line creates an alias names MyFloat.

MyFloat = Simulink.AliasType;

7-8

Simulink.AliasType

The following notations get and set the properties of a data type alias, respectively,

PROPVALUE = ALIAS.PROPNAME;

ALIAS.PROPNAME = PROPVALUE;

where ALIAS is the name of the alias object, PROPNAME is the name of the alias object’s properties, and PROPVALUE is the property’s value. For example, the following code saves the current value of MyFloat’s BaseType property and assigns it a new value.

old = MyFloat.BaseType; MyFloat.BaseType = 'single';

See “Properties” on page 7-13 for information on the names, permitted values, and usage of the properties of data type alias objects.

Data Type Aliases in the Generated Code

If you have a Simulink Coder license, you can cause data type aliases to appear in the code generated for a model using any of the following methods.

Specifying the signal data type of a block in the model as a

Simulink.AliasType via the Block Parameters dialog box.

Creating a Simulink.Signal object that uses the Simulink.AliasType as its data type. Use this signal

object as the name of a signal in the model and specify that the signal name must resolve to an object in the MATLAB workspace. See “Signal Objects” in the Simulink Coder User’s Guide for more information.

Creating a Simulink.Parameter object that uses the Simulink.AliasType as its data type. Use this parameter object as a block parameter in the model. See “Generated Code for

Parameter Data Types” in the Simulink Coder User’s Guide for more information.

7-9

Simulink.AliasType

Notes

If you assign a data type in a block’s Block Parameters dialog box and by using a Simulink.Signal object on the signal feeding into the block, the code is always generated using the data type in the dialog box.

The Simulink Coder code generator tries to preserve the names of alias types in the generated code. However, in some cases, an alias type name might revert to its underlying equivalent built-in data type. If you have a Embedded Coder license, you can guarantee that the code generator uses the alias type name in the generated code, by using replacement types (see “Data Type Replacement” in the Embedded Coder documentation).

The Simulink.AliasType class does not support multiword data types for code generation.

Parent None

Children None

7-10

Simulink.AliasType

Property

Dialog

Box

Base type

The data type to which this alias refers. The default is double. To specify another data type, select the data type from the adjacent pull-down list of standard data types or enter the data type’s name in the edit field. Note that you can, with one exception, specify a nonstandard data type, e.g., a data type defined by a Simulink.NumericType object, by entering the data type’s name in the edit field. The exception is a Simulink.NumericType whose

Category is Fixed-point: unspecified scaling.

7-11

Simulink.AliasType

Note Fixed-point: unspecified scaling is a partially specified type whose definition is completed by the block that uses the Simulink.NumericType. Forbidding its use in alias types avoids creating aliases that have different base types depending on where they are used.

Data scope

Specifies whether the data type definition should be imported from, or exported to, a header file during code generation. The possible values are:

 

Value

Action

 

 

Auto (default)

If no value is specified for Header file, export

 

 

 

the type definition to model_types.h, where

 

 

 

model is the model name.

 

 

 

If a value is specified for Header file, import

 

 

 

the data type definition from the specified

 

 

 

header file.

 

 

Exported

Export the data type definition to a header

 

 

 

file, which can be specified in the Header

 

 

 

file field. If no value is specified for Header

 

 

 

file, the header file name defaults to type.h,

 

 

 

wheretype is the data type name.

 

 

Imported

Import the data type definition from a header

 

 

 

file, which can be specified in the Header

 

 

 

file field. If no value is specified for Header

 

 

 

file, the header file name defaults to type.h,

 

 

 

wheretype is the data type name.

 

Header file

Name of a C header file from which a data type definition is imported, or to which a data type definition is exported, based on

7-12

Simulink.AliasType

Properties

See Also

the value of Data scope. If this field is specified, the specified name is used during code generation for importing or exporting. If this field is empty, the value defaults to type.h if Data scope equals Imported or Exported, or defaults to model_types.h if

Data scope equals Auto.

Description

Describes the usage of the data type referenced by this alias.

 

Name

Description

 

 

BaseType

A string specifying the name of a standard or custom

 

 

 

data type. (Base type)

 

 

DataScope

A string specifying whether the data type definition

 

 

 

should be imported from, or exported to, a header file

 

 

 

during code generation. (Data scope)

 

 

Description

A string that describes the usage of the data type.

 

 

 

May be a null string. (Description)

 

 

HeaderFile

A string that specifies the name of a C header file

 

 

 

from which a data type definition is imported, or to

 

 

 

which a data type definition is exported, during code

 

 

 

generation. (Header file)

 

“Generate Code Including User-Defined Data Types” in the Embedded Coder documentation

7-13

Simulink.Annotation

Purpose

Specify properties of model annotation

Description

Instances of this class specify the properties of annotations. You can

 

use getCallbackAnnotation in an annotation callback function to get

 

the Simulink.Annotation instance for the annotation associated with

 

the callback function. You can use find_system and get_param to get

 

the Simulink.Annotation instance associated with any annotation in

 

a model. For example, the following code gets the annotation object

 

for the first annotation in the currently selected model and turns on

 

its drop shadow

 

ah = find_system(gcs, 'FindAll', 'on', 'type', 'annotation');

 

ao = get_param(ah(1), 'Object');

 

ao.DropShadow = 'on';

Children

None.

Property

Summary

 

Property

Description

Values

 

 

Text

String specifying text of

string

 

 

 

annotation. Same as Name.

 

 

 

ClickFcn

Specifies MATLAB code to

string

 

 

 

be executed when a user

 

 

 

 

single-clicks this annotation.

 

 

 

 

Simulink software stores

 

 

 

 

the code entered in this

 

 

 

 

field with the model. See

 

 

 

 

“Associate Click Functions

 

 

 

 

with Annotations” for more

 

 

 

 

information.

 

 

 

Description

String that describes this

string

 

 

 

annotation.

 

 

7-14

Simulink.Annotation

 

Property

Description

Values

 

 

FontAngle

String specifying the angle

'normal' | 'italic' |

 

 

 

of the annotation’s font.

'oblique' | {'auto'}

 

 

 

The default value, 'auto',

 

 

 

 

specifies use of the model’s

 

 

 

 

preferred font angle.

 

 

 

FontName

String specifying name of

string

 

 

 

annotation’s font. The default

 

 

 

 

value, 'auto', specifies use of

 

 

 

 

the model’s preferred font.

 

 

 

FontSize

Integer specifying size of

real {'-1'}

 

 

 

annotation’s font in points.

 

 

 

 

The default value, -1, specifies

 

 

 

 

use of the model’s preferred

 

 

 

 

font size.

 

 

 

FontWeight

String specifying the weight

'light' | 'normal' | 'demi' |

 

 

 

of the annotation’s font.

'bold' | {'auto'}

 

 

 

The default value, 'auto',

 

 

 

 

specifies use of the model’s

 

 

 

 

preferred font weight.

 

 

 

Handle

Annotation handle.

real

 

 

HiliteAncestors

For internal use.

 

 

 

Name

String specifying text of

string

 

 

 

annotation. Same as Text.

 

 

 

Selected

String specifying whether

{'on'} | 'off'

 

 

 

this annotation is currently

 

 

 

 

selected ('on’) or not selected

 

 

 

 

('off').

 

 

 

Parent

String specifying parent name

string

 

 

 

of annotation object.

 

 

 

Path

Path to the annotation.

string

 

 

 

 

 

 

7-15

Simulink.Annotation

 

Property

Description

Values

 

 

 

Position

Two-element vector specifying

vector [left bottom]

 

 

 

 

the x-y coordinates of this

not enclosed in quotation marks.

 

 

 

annotation relative to the

The maximum value for a

 

 

 

top, left corner of the block

coordinate is 32767.

 

 

 

diagram, e.g., [236 83].

 

 

 

 

Horizontal-

String specifying the

{'center'} | 'left'|'right'

 

 

 

Alignment

horizontal alignment of this

 

 

 

 

 

annotation, e.g., 'center'.

 

 

 

 

VerticalAlignment

String specifying the vertical

{'middle'} |

 

 

 

 

alignment of this annotation,

'top'|'cap'|'baseline'|'bottom'

 

 

 

e.g., 'middle'.

 

 

 

 

ForegroundColor

String specifying foreground

RGB value array string |

 

 

 

 

color of this annotation.

[r,g,b,a] where r, g, b,

 

 

 

 

and a are the red, green, blue, and

 

 

 

 

alpha values of the color normalized

 

 

 

 

to the range 0.0 to 1.0, delineated

 

 

 

 

with commas. The alpha value is

 

 

 

 

optional and ignored.

 

 

 

 

Block background color can also be

 

 

 

 

'black', 'white', 'red', 'green',

 

 

 

 

'blue', 'cyan', 'magenta',

 

 

 

 

'yellow', 'gray', 'lightBlue',

 

 

 

 

'orange', 'darkGreen'.

 

 

7-16

Simulink.Annotation

 

Property

Description

Values

 

 

BackgroundColor

String specifying background

RGB value array string |

 

 

 

color of this annotation.

[r,g,b,a] where r, g, b,

 

 

 

 

and a are the red, green, blue, and

 

 

 

 

alpha values of the color normalized

 

 

 

 

to the range 0.0 to 1.0, delineated

 

 

 

 

with commas. The alpha value is

 

 

 

 

optional and ignored.

 

 

 

 

Block background color can also be

 

 

 

 

'black', 'white', 'red', 'green',

 

 

 

 

'blue', 'cyan', 'magenta',

 

 

 

 

'yellow', 'gray', 'lightBlue',

 

 

 

 

'orange', 'darkGreen'.

 

 

DropShadow

String specifying whether

'on' | {'off'}

 

 

 

to display a drop shadow.

 

 

 

 

Options are 'on' or 'off'.

 

 

 

TeXMode

String specifying whether to

'on' | {'off'}

 

 

 

render TeX markup. Options

 

 

 

 

are 'on' or 'off'.

 

 

 

Type

Annotation type. This is

string

 

 

 

always 'annotation'

 

 

 

LoadFcn

String specifying M-code

string

 

 

 

to be executed when the

 

 

 

 

model containing this

 

 

 

 

annotation is loaded. See

 

 

 

 

“Annotation Callback

 

 

 

 

Functions” in the online

 

 

 

 

Simulink documentation.

 

 

7-17

Simulink.Annotation

 

Property

Description

Values

 

 

DeleteFcn

String specifying M-code

string

 

 

 

to be executed before

 

 

 

 

deleting this annotation.

 

 

 

 

See “Annotation Callback

 

 

 

 

Functions” in the online

 

 

 

 

Simulink documentation.

 

 

 

RequirementInfo

For internal use.

string

 

 

Tag

User-specified text that is

string

 

 

 

assigned to the annotation’s

 

 

 

 

Tag parameter and saved with

 

 

 

 

the annotation.

 

 

 

UseDisplayText-

String specifying whether to

'on' | {'off'}

 

 

AsClickCallback

use the contents of the Text

 

 

 

 

property as this annotation’s

 

 

 

 

click function. Options are

 

 

 

 

'on' or 'off'.

 

 

 

 

If set to 'on', the text of the

 

 

 

 

annotation is interpreted as a

 

 

 

 

valid MATLAB expression and

 

 

 

 

run. If set to 'off', clicking

 

 

 

 

on the annotation runs the

 

 

 

 

click function, if there is one.

 

 

 

 

If there is no click function,

 

 

 

 

clicking the annotation has no

 

 

 

 

effect.

 

 

 

 

See “Associate Click Functions

 

 

 

 

with Annotations” in the

 

 

 

 

Simulink documentation for

 

 

 

 

more information.

 

 

 

UserData

Any data that you want to

vector

 

 

 

associate with this annotation.

 

 

7-18

Simulink.BlockCompDworkData

Purpose

Description

Parent

Children

Property

Summary

Properties

Provide postcompilation information about block’s DWork vector

Simulink software returns an instance of this class when a MATLAB program, e.g., a Level-2 MATLAB S-function, invokes the “Dwork” on page 7-175 method of a block’s run-time object after the model containing the block has been compiled.

Simulink.BlockData

None

 

Name

Description

 

 

“Usage” on page 7-19

Usage type of this DWork vector.

 

 

“UsedAsDiscState”

True if this DWork vector is being used to

 

 

 

store the values of a block’s discrete states.

 

Usage

Description

Returns a string indicating how this DWork vector is used. Permissible values are:

DWork

DState

Scratch

Mode

Data Type string

Access

RW for MATLAB S-function blocks, RO for other blocks.

7-19

Simulink.BlockCompDworkData

UsedAsDiscState

Description

True if this DWork vector is being used to store the values of a block’s discrete states.

Data Type

Boolean

Access

RW for MATLAB S-Function blocks, RO for other blocks.

7-20

Simulink.BlockCompInputPortData

Purpose

Description

Parent

Children

Property

Summary

Properties

Provide postcompilation information about block input port

Simulink software returns an instance of this class when a MATLAB program, e.g., a Level-2 MATLAB S-function, invokes the “InputPort” on page 7-176 method of a block’s run-time object after the model containing the block has been compiled.

Simulink.BlockPortData

None

 

Name

Description

 

 

“DirectFeedthrough”

True if this port has direct feedthrough.

 

 

“Overwritable”

True if this port is overwritable.

 

 

 

 

 

DirectFeedthrough

Description

True if this input port has direct feedthrough.

Data Type

Boolean

Access

RW for MATLAB S functions, RO for other blocks.

Overwritable

Description

True if this input port is overwritable.

Data Type

Boolean

Access

RW for MATLAB S functions, RO for other blocks.

7-21

Simulink.BlockCompOutputPortData

Purpose

Description

Parent

Children

Property

Summary

Properties

Provide postcompilation information about block output port

Simulink software returns an instance of this class when a MATLAB program, e.g., a Level-2 MATLAB S-function, invokes the “OutputPort” on page 7-177 method of a block’s run-time object after the model containing the block has been compiled.

Simulink.BlockPortData

None

 

Name

Description

 

 

“Reusable”

Specifies whether an output port’s memory

 

 

 

is reusable.

 

 

 

 

 

Reusable

Description

Specifies whether an output port’s memory is reusable. Options are:

NotReusableAndGlobal and ReusableAndLocal.

Data Type string

Access

RW for MATLAB S functions, RO for other blocks.

7-22

Simulink.BlockData

Purpose

Description

Parent

Children

Property

Summary

Provide run-time information about block-related data, such as block parameters

This class defines properties that are common to objects that provide run-time information about a block’s ports and work vectors.

None

Simulink.BlockPortData, Simulink.BlockCompDworkData

 

Name

Description

 

 

“AliasedThroughDataType”

Fundamental base data type.

 

 

on page 7-24

 

 

 

“AliasedThroughDataType-

Fundamental base data type ID.

 

 

ID” on page 7-25

 

 

 

“Complexity”

Numeric type (real or complex) of the

 

 

 

block data.

 

 

“Data”

The block data.

 

 

“DataAsDouble”

The block data in double form.

 

 

“Datatype”

Data type of the block data.

 

 

“DatatypeID”

Index of the data type of the block

 

 

 

data.

 

 

“Dimensions”

Dimensions of the block data.

 

 

“Name”

Name of the block data.

 

 

“Type”

Type of block data (e.g., a parameter).

 

 

 

 

 

7-23

Simulink.BlockData

Properties

AliasedThroughDataType

Description

Data type aliases allow a data type (B) to be recursively aliased to another alias type or BaseType (A). If alias type A is aliased to another alias type that is aliased to another alias type and so forth, this property allows the alias type to be iteratively searched (aliased through) until the type is no longer an alias type and that final result is the value of the property returned. For example, assume that you have created the Simulink Alias types A and B as follows:

A=Simulink.AliasType('double')

A=

Simulink.AliasType Description: ''

HeaderFile: '' BaseType: 'double'

B=Simulink.AliasType('A')

B=

Simulink.AliasType

Description: ''

HeaderFile: ''

BaseType: 'A'

If the data type of an item of block data is B, this property returns the base type A instead of B.

Data Type string

Access

RO

7-24

Simulink.BlockData

AliasedThroughDataTypeID

Description

Index of the data type alias returned by the AliasedThroughDataType property.

Data Type integer

Access

RO

Complexity

Description

Numeric type (real or complex) of the block data.

Data Type string

Access

RW for MATLAB S functions, RO for other blocks.

Data

Description

The block data.

Data Type

The data type specified by the “Datatype” or “DatatypeID” properties of this object.

Access

RW

7-25

Simulink.BlockData

DataAsDouble

Description

The block data’s in double form.

Data Type double

Access

RO

Datatype

Description

Data type of the values of the block-related object.

Data Type string

Access

RO

DatatypeID

Description

Index of the data type of the values of the block-related object. enter the numeric value for the desired data type, as follows:

Data Type

Value

'inherited'

-1

'double'

0

'single'

1

'int8'

2

'uint8'

3

'int16'

4

'uint16'

5

 

 

7-26

Simulink.BlockData

Data Type

Value

'int32'

6

'uint32'

7

'boolean' or fixed-point data types

8

 

 

Data Type integer

Access

RW for MATLAB S functions, RO for other blocks

Dimensions

Description

Dimensions of the block-related object, e.g., parameter or DWork vector.

Data Type array

Access

RW for MATLAB S functions, RO for other blocks

Name

Description

Name of block-related object, e.g., a block parameter or DWork vector.

Data Type string

Access

RW for MATLAB S functions, RO for other blocks

Type

Description

Type of block data. Possible values are:

7-27

Simulink.BlockData

 

Type

Description

 

 

'BlockPreCompInputPortData'

This object contains data for an

 

 

 

input port before the model is

 

 

 

compiled.

 

 

'BlockPreCompOutputPortData'

This object contains data for an

 

 

 

output port before the model is

 

 

 

compiled.

 

 

'BlockCompInputPortData'

This object contains data for an

 

 

 

input port after the model is

 

 

 

compiled.

 

 

'BlockCompOutputPortData'

This object contains data for an

 

 

 

output port after the model is

 

 

 

compiled.

 

 

'BlockPreCompDworkData'

This object contains data for a

 

 

 

DWork vector before the model is

 

 

 

compiled.

 

 

'BlockCompDworkData'

This object contains data for a

 

 

 

DWork vector after the model is

 

 

 

compiled.

 

 

'BlockDialogPrmData'

This object describes a dialog box

 

 

 

parameter of a Level-2 MATLAB

 

 

 

S-function.

 

 

'BlockRuntimePrmData'

This object describes a run-time

 

 

 

parameter of a Level-2 MATLAB

 

 

 

S-function.

 

 

'BlockCompContStatesData'

This object describes the

 

 

 

continuous states of the block at

 

 

 

the current time step.

 

 

'BlockDerivativesData'

This object describes the

 

 

 

derivatives of the block’s

 

 

 

continuous states at the current

 

 

 

time step.

 

7-28

Simulink.BlockData

Data Type string

Access

RO

7-29

Simulink.BlockPath

Purpose

Description

Property

Summary

Method

Summary

Fully specified Simulink block path

A Simulink.BlockPath object represents a fully specified block path that uniquely identifies a block within a model hierarchy, including model reference hierarchies that involve multiple instances of a referenced model. Simulink uses block path objects in a variety of contexts. For example, when you specify Normal mode visibility, Simulink uses block path objects to identify the models with Normal mode visibility (for details, see “Set Normal Mode Visibility”.

The Simulink.BlockPath class is very similar to the

Simulink.SimulationData.BlockPath class.

You must have Simulink installed to use the Simulink.BlockPath class. However, you do not have to have Simulink installed to use the Simulink.SimulationDataBlockPath class. For Simulink environments, consider using Simulink.BlockPath instead of

Simulink.SimulationData.BlockPath. The Simulink.BlockPath class includes a method for checking the validity of block path objects, without you having to update the model diagram.

 

Name

 

Description

 

 

SubPath

 

Individual component within the block

 

 

 

 

specified by the block path

 

 

 

 

 

 

Name

Description

 

 

BlockPath

Create a block path.

 

 

convertToCell

Convert a block path to a cell array of strings.

 

 

getBlock

Get a single block path in the model reference

 

 

 

hierarchy.

 

 

getLength

Get the length of the block path.

 

 

validate

Determine whether the block path represents

 

 

 

a valid block hierarchy.

 

7-30

Simulink.BlockPath

Properties

SubPath

Description

Represents an individual component within the block specified by the block path.

For example, if the block path refers to a Stateflow chart, you can use SubPath to indicate the chart signals. For example:

Block Path:

'sf_car/shift_logic'

SubPath:

'gear_state.first'

Data Type string

Access

RW

Methods

BlockPath

Purpose

Create block path

Syntax blockpath_object blockpath_object blockpath_object blockpath_object

=Simulink.BlockPath()

=Simulink.BlockPath(blockpath)

=Simulink.BlockPath(paths)

=Simulink.BlockPath(paths, subpath)

Input Arguments

blockpath

Block path object that you want to copy.

paths

A string or cell array of strings that Simulink uses to build the block path.

7-31

Simulink.BlockPath

Specify each string in order, from the top model to the specific block for which you are creating a block path.

Each string must be a path to a block within the Simulink model. The block must be:

A block in a single model

A Model block (except for the last string, which may be a block other than a Model block)

A block that is in a model that is referenced by a Model block that is specified in the previous string

When you create a block path for specifying Normal mode visibility:

The first string must represent a block that is in the top model in the model reference hierarchy.

Strings must represent Model blocks that are in Normal mode.

Strings that represent variant models or variant subsystems must refer to an active variant.

You can use gcb in the cell array to specify the currently selected block.

subpath

String that represents an individual component within a block.

Output Arguments

blockpath_object

Block path that you create.

Description

blockpath_object = Simulink.BlockPath() creates an empty block path.

7-32

Simulink.BlockPath

blockpath_object = Simulink.BlockPath(blockpath) creates a copy of the block path of the block path object that you specify with the source_blockpath argument.

blockpath = Simulink.BlockPath(paths) creates a block path from the cell array of strings that you specify with the paths argument. Each string represents a path at a level of model hierarchy. Simulink builds the full block path based on the strings.

blockpath = Simulink.BlockPath(paths, subpath) creates a block path from the string or cell array of strings that you specify with the paths argument and creates a path for the individual component (for example, a signal) of the block.

Example

Create a block path object called bp1, using gcb to get the current block.

sldemo_mdlref_depgraph

bp1 = Simulink.BlockPath(gcb)

The resulting block path is the top-level Model block called thermostat (the top-left Model block.

bp1 =

Simulink.BlockPath

Package: Simulink

Block Path:

'sldemo_mdlref_depgraph/thermostat'

Create a block path object called bp2, using a cell array of strings representing elements of the block path.

sldemo_mdlref_depgraph

bp2 = Simulink.BlockPath({'sldemo_mdlref_depgraph/thermostat', ...

'sldemo_mdlref_heater/Fahrenheit to Celsius', ...

'sldemo_mdlref_F2C/Gain1'})

7-33

Simulink.BlockPath

The resulting block path reflects the model reference hierarchy for the block path

bp2 =

Simulink.BlockPath

Package: Simulink

Block Path: 'sldemo_mdlref_depgraph/thermostat'

'sldemo_mdlref_heater/Fahrenheit to Celsius' 'sldemo_mdlref_F2C/Gain1'

convertToCell

Purpose

Convert block path to cell array of strings

Syntax

cellarray = Simulink.BlockPath.convertToCell()

Output Arguments

cellarray

Cell array of strings representing elements of block path.

Description

cellarray = Simulink.BlockPath.convertToCell() converts a block path to a cell array of strings.

Examples

sldemo_mdlref_depgraph

bp2 = Simulink.BlockPath({'sldemo_mdlref_depgraph/thermostat', ...

'sldemo_mdlref_heater/Fahrenheit to Celsius', ...

'sldemo_mdlref_F2C/Gain1'})

cellarray_for_bp2 = bp2.convertToCell()

The result is a cell array representing the elements of the block path.

cellarray_for_bp2 =

7-34

Simulink.BlockPath

'sldemo_mdlref_depgraph/thermostat' 'sldemo_mdlref_heater/Fahrenheit to Celsius' 'sldemo_mdlref_F2C/Gain1'

getBlock

Purpose

Get block path in model reference hierarchy

Syntax

block = Simulink.BlockPath.getBlock(index)

Input Arguments

index

The index of the block for which you want to get the block path. The index reflects the level in the model reference hierarchy. An index of 1 represents a block in the top-level model, an index of 2 represents a block in a model referenced by the block of index 1, and an index of n represents a block that the block with index n-1 references.

Output Arguments

block

The block representing the level in the model reference hierarchy specified by the index argument.

Description

blockpath = Simulink.BlockPath.getBlock(index) returns the block path of the block specified by the index argument.

Example

Get the block for the second level in the model reference hierarchy.

sldemo_mdlref_depgraph

bp2 = Simulink.BlockPath({'sldemo_mdlref_depgraph/thermostat', ...

'sldemo_mdlref_heater/Fahrenheit to Celsius', ...

'sldemo_mdlref_F2C/Gain1'})

7-35

Simulink.BlockPath

blockpath = bp2.getBlock(2)

The result is the thermostat block, which is at the second level in the block path hierarchy.

blockpath =

sldemo_mdlref_heater/Fahrenheit to Celsius

getLength

Purpose

Get length of block path

Syntax

length = Simulink.BlockPath.getLength()

Output Arguments

length

The length of the block path. The length is the number of levels in the model reference hierarchy.

Description

length = Simulink.BlockPath.getLength() returns a numeric value that corresponds to the number of levels in the model reference hierarchy for the block path.

Example

Get the length of block path bp2.

sldemo_mdlref_depgraph

bp2 = Simulink.BlockPath({'sldemo_mdlref_depgraph/thermostat', ...

'sldemo_mdlref_heater/Fahrenheit to Celsius', ...

'sldemo_mdlref_F2C/Gain1'})

length_bp2 = bp2.getLength()

The result reflects that the block path has three elements.

length_bp2 =

7-36

Simulink.BlockPath

3

validate

Purpose

Determine whether block path represents valid block hierarchy

Syntax

Simulink.BlockPath.validate()

Simulink.BlockPath.validate(AllowInactiveVariant)

Input Arguments

AllowInactiveVariant

Set to true to include inactive variants in the validity checking.

The default is false.

Description

Simulink.BlockPath.validate() determines whether the block path represents a valid block hierarchy. If there are any validity issues, messages appear in the MATLAB command window. The method checks that:

All elements in the block path represent valid blocks.

All variant elements are active.

Each element except for the last element:

-

-

Is a valid Model block

References the model of the next element

Simulink.BlockPath.validate(AllowInactiveVariant) Specifying true causes the validity checking to consider inactive variants as being valid, if they meet the other validity checks described above. Omitting the AllowInactiveVariant argument or specifying its default value of false causes the method to check only the active variant.

Example

Validate the block paths, checking only the active variant. This validation fails, because the block path actually references model

7-37

Simulink.BlockPath

 

sldemo_mrv_nonlinear_controller, while bp specifies that the block

 

references model sldemo_mdlref_second_order_controller, which

 

is in an inactive variant.

 

sldemo_mdlref_variants

 

bp = Simulink.BlockPath({'sldemo_mdlref_variants/Controller', ...

 

'sldemo_mrv_second_order_controller/sensor1'})

 

bp.validate()

 

Validate by checking all variants. The block path passes the validation

 

when inactive variants are also checked.

 

bp.validate(true)

See Also

Simulink.SimulationData.BlockPath |

 

Simulink.SimulationData.Dataset

How To

• “Specify the Instance That Has Normal Mode Visibility”

7-38

Simulink.BlockPortData

Purpose

Description

Parent

Children

Property

Summary

Properties

Describe block input or output port

This class defines properties that are common to objects that provide run-time information about a block’s ports.

Simulink.BlockData

Simulink.BlockPreCompInputPortData,

Simulink.BlockPreCompOutputPortData,

Simulink.BlockCompInputPortData,

Simulink.BlockCompOutputPortData

 

Name

Description

 

 

“IsBus”

True if this port is connected to a bus.

 

 

“IsSampleHit”

True if this port produces output or

 

 

 

accepts input at the current simulation

 

 

 

time step.

 

 

“SampleTime”

Sample time of this port.

 

 

“SampleTimeIndex”

Sample time index of this port.

 

 

“SamplingMode”

Sampling mode of the port.

 

 

 

 

 

IsBus

Description

True if this port is connected to a bus.

Data Type

Boolean

Access

RO

7-39

Simulink.BlockPortData

IsSampleHit

Description

True if this port produces output or accepts input at the current simulation time step.

Data Type

Boolean

Access

RO

SampleTime

Description

Sample time of this port.

Data Type

[period offset] where period and offset are values of type double. See “Specify Sample Time” for more information.

Access

RW for MATLAB S functions, RO for other blocks

SampleTimeIndex

Description

Sample time index of this port.

Data Type integer

Access

RO

SamplingMode

Description

Sampling mode of the port. Valid values are:

7-40

Simulink.BlockPortData

 

Value

Description

 

 

'frame'

Port accepts or outputs frame-based

 

 

 

signals. The use of frame-based signals

 

 

 

requires a DSP System Toolbox license.

 

 

'inherited'

Sampling mode is inherited from the port

 

 

 

to which this port is connected.

 

 

'sample'

Port accepts or outputs sampled data.

 

 

Data Type

 

 

 

string

 

 

Access

RW for MATLAB S functions, RO for other blocks

7-41

Simulink.BlockPreCompInputPortData

Purpose

Description

Parent

Children

Property

Summary

Properties

Provide precompilation information about block input port

Simulink software returns an instance of this class when a MATLAB program, e.g., a Level-2 MATLAB S-function, invokes the “InputPort” on page 7-176 method of a block’s run-time object before the model containing the block has been compiled.

Simulink.BlockPortData

None

 

Name

Description

 

 

“DirectFeedthrough”

True if this port has direct feedthrough.

 

 

“Overwritable”

True if this port is overwritable.

 

 

 

 

 

DirectFeedthrough

Description

True if this input port has direct feedthrough.

Data Type

Boolean

Access

RW for MATLAB S functions, RO for other blocks

Overwritable

Description

True if this input port is overwritable.

Data Type

Boolean

Access

RW for MATLAB S functions, RO for other blocks

7-42

Simulink.BlockPreCompOutputPortData

Purpose

Description

Parent

Children

Property

Summary

Properties

Provide precompilation information about block output port

Simulink software returns an instance of this class when a MATLAB program, e.g., a Level-2 MATLAB S-function, invokes the “OutputPort” on page 7-177 method of a block’s run-time object before the model containing the block has been compiled.

Simulink.BlockPortData

none

 

Name

Description

 

 

“Reusable”

Specifies whether an output port’s memory is

 

 

 

reusable.

 

 

 

 

 

Reusable

Description

Specifies whether an output port’s memory is reusable. Options are:

NotReusableAndGlobal and ReusableAndLocal.

Data Type string

Access

RW for MATLAB S functions, RO for other blocks

7-43

Simulink.Bus

Purpose

Specify properties of signal bus

Description Objects of this class (in conjunction with objects of the Simulink.BusElement class) specify the properties of a signal bus. Use bus objects to enable Simulink software to validate the properties of buses connected to the inputs of blocks in your model. You do this by entering, in the Data type parameter of a block parameter dialog box, the name of a bus object that defines a bus. When you update the model diagram or start a simulation of the model, Simulink checks whether the buses connected to the blocks have the properties specified by the bus objects. If not, Simulink halts and displays an error message.

The blocks that support using a bus object as a data type are:

Bus Creator

Constant

Data Store Memory

Data Store Read

Data Store Write

Inport

Outport

Signal Specification

You can use the Model Explorer Add > Simulink Bus command (see “Using the Model Explorer to Create Data Objects”), the Simulink Bus editor (see “Manage Bus Objects with the Bus Editor”), or MATLAB commands (see “Data Objects”) to create bus objects in the base MATLAB workspace. You must use the Bus editor or the MATLAB command line to set the properties of a bus object. Simulink also provides a set of utility functions for creating and saving bus objects.

To view bus object properties:

1 Open the Model Explorer.

7-44

Simulink.Bus

2In the Model Hierarchy pane, select the Base Workspace node.

3In the Contents pane, select the bus object. In the Property dialog box appears.

Property

Dialog

Box

7-45

Simulink.Bus

Bus elements

Table that displays the properties of the bus elements. You cannot edit this table. You must use either the Simulink Bus editor (see “Bus Objects”) or MATLAB commands to add or delete bus elements or change the properties of existing bus elements. To launch the bus editor, click the Launch Bus editor button at the bottom of this dialog box or in the Simulink Editor, select

Edit > Bus EditorBus editor.

Data scope

Specifies whether the data type definition should be imported from, or exported to, a header file during code generation. The possible values are:

 

Value

Action

 

 

Auto (default)

If no value is specified for Header file, export

 

 

 

the data type definition to model_types.h,

 

 

 

where model is the model name.

 

 

 

If a value is specified for Header file, import

 

 

 

the data type definition from the specified

 

 

 

header file.

 

 

Exported

Export the data type definition to a header

 

 

 

file, which can be specified in the Header

 

 

 

file field. If no value is specified for Header

 

 

 

file, the header file name defaults to type.h,

 

 

 

wheretype is the data type name.

 

 

Imported

Import the data type definition from a header

 

 

 

file, which can be specified in the Header

 

 

 

file field. If no value is specified for Header

 

 

 

file, the header file name defaults to type.h,

 

 

 

wheretype is the data type name.

 

Header file

Name of a C header file from which a data type definition is imported, or to which a data type definition is exported, based

7-46

Simulink.Bus

Properties

on the value of Data scope. This field is intended for use by Simulink Coder software. See “Generate Code Including

User-Defined Data Types”. Simulink software ignores this field.

Alignment

Data alignment boundary, specified in number of bytes. The starting memory address for the data allocated for the bus will be a multiple of the Alignment setting. The default value is -1, which specifies that the code generator should determine an optimal alignment based on usage. Otherwise, specify a positive integer that is a power of 2, not exceeding 128. This field is

intended for use by Simulink Coder software. See “Configure Data Alignment for Function Implementations”. Simulink software ignores this field.

Description

Description of this structure. This field is intended for you to use to document this bus. Simulink software does not use this field.

 

Name

Access

Description

 

 

Alignment

RW

Integer value specifying a data

 

 

 

 

alignment boundary, in number of

 

 

 

 

bytes. This property is intended for

 

 

 

 

use by Simulink Coder software.

 

 

 

 

Simulink software does not use it.

 

 

 

 

(Alignment)

 

 

DataScope

RW

A string specifying whether the data

 

 

 

 

type definition should be imported

 

 

 

 

from, or exported to, a header file

 

 

 

 

during code generation. (Data scope)

 

 

Description

RW

A string that describes this bus. This

 

 

 

 

property is intended for user use.

 

 

 

 

Simulink software does not use it.

 

 

 

 

(Description)

 

7-47

Simulink.Bus

 

 

Name

Access

Description

 

 

 

Elements

RW

An array of Simulink.BusElement

 

 

 

 

 

objects that define the names,

 

 

 

 

 

data types, dimensions, and other

 

 

 

 

 

properties of the bus’s elements. The

 

 

 

 

 

elements must have unique names

 

 

 

 

 

(see “Choosing a Signal Name”). (Bus

 

 

 

 

 

elements)

 

 

 

HeaderFile

RW

A string that specifies the name of a

 

 

 

 

 

C header file from which a data type

 

 

 

 

 

definition is imported, or to which

 

 

 

 

 

a data type definition is exported,

 

 

 

 

 

during code generation. This property

 

 

 

 

 

is intended for use by Simulink Coder

 

 

 

 

 

software. Simulink software does not

 

 

 

 

 

use it. (Header file)

 

See Also

“Composite Signals”, Bus Assignment, Bus Creator, Bus Selector,

 

 

 

Bus to Vector, Constant, Inport, Outport, Signal Specification,

 

 

 

Simulink.Bus.cellToObject,

Simulink.Bus.createMATLABStruct,

 

 

 

Simulink.Bus.createObject,

Simulink.BusElement,

 

 

 

Simulink.Bus.objectToCell, Simulink.Bus.save

 

7-48

Simulink.BusElement

Purpose

Describe element of signal bus

Description Objects of this class define elements of buses defined by objects of the

Simulink.Bus class.

Property

Dialog

Box

Name

Name of this element. See “Signal Names” for guidelines for signal names.

Data Type: string

Access: RW

DataType

Name of the data type of this element. The value of this field can be a:

Built-in Simulink data type (for example, double or uint8)

7-49

Simulink.BusElement

Simulink.NumericType object, with one exception. The exception is a Simulink.NumericType whose Category is Fixed-point: unspecified scaling.

Note Fixed-point: unspecified scaling is a partially specified type whose definition is completed by the block that uses the Simulink.NumericType. Forbidding its use for bus elements avoids creating bus elements that have different data types depending on where they are used.

Simulink.Bus object, using the Bus: <object name> option. This allows you to create bus objects that specify hierarchical buses (that is, buses that contain other buses).

Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Data type parameter. (See “Specify Data Types Using Data Type Assistant”.)

Data Type: string

Access: RW

Dimensions

A vector specifying the dimensions of this element.

Data Type: array.

Access: RW

Complexity

Numeric type (real or complex) of this element. Must be real if this bus element is itself a bus.

Data Type: string

Access: RW

7-50

Simulink.BusElement

SampleTime

Size of the interval between times when this signal value must be recomputed. Must be -1 (inherited) if this bus element is itself a bus or if the bus that includes this element passes through a block that changes the bus’s sample time, such as a Rate Transition block. See “Specify Sample Time” for more information.

Data Type: double

Access: RW

Min

The minimum value of this element. This value must be a finite real double scalar. This value must be empty [] if this element is itself a bus.

Data Type: double

Access: RW

Max

The maximum value of this element. This value must be a finite real double scalar. This value must be empty [] if this element is itself a bus.

Data Type: double

Access: RW

SamplingMode

Sampling mode of this element. Must be sample-based if this element is itself a bus. This field is intended to be used by applications based on Simulink models.

Data Type: string

Access: RW

7-51

Simulink.BusElement

 

DimensionsMode

 

A field that specifies if the size (the number of elements in a dimension)

 

of this element may vary or remain fixed during simulation. This field

 

can have the following values:

 

Fixed: The size of the element may not change during simulation.

 

Variable: The size of the element may change during simulation.

 

See “Variable-Size Signal Basics” for more information.

 

Data Type: string

 

Access: RW

See Also

“Composite Signals”, Bus Assignment, Bus Creator, Bus Selector,

 

Bus to Vector, Simulink.Bus, Simulink.Bus.cellToObject,

 

Simulink.Bus.createObject, Simulink.Bus.objectToCell,

 

Simulink.Bus.save

7-52

Simulink.ConfigSet

Purpose

Description

Property

Summary

Access model configuration set

Instances of this handle class allow you to write programs to create, modify, and attach configuration sets to models. See “Manage a Configuration Set” and “Overview” for more information.

 

Name

Description

 

 

“Components”

Components of the configuration set.

 

 

“Description”

Description of the configuration set.

 

 

“Name”

Name of the configuration set.

 

 

 

 

 

Method

Summary

Note You can use the Model Configuration dialog box to set the Name and Description properties of a configuration set. See “Model Configuration Pane” for more information.

 

Name

Description

 

 

“attachComponent”

Attach a component to a configuration set.

 

 

“copy”

Create a copy of a configuration set.

 

 

“getComponent”

Get a component of a configuration set.

 

 

“getFullName”

Get the full path of a configuration set.

 

 

“getModel”

Get the handle of the model that owns a

 

 

 

configuration set.

 

 

“get_param”

Get the value of a configuration set parameter.

 

 

“isActive”

Determine whether a configuration set is the

 

 

 

active set of the model that owns it.

 

 

“isValidParam”

Determine whether a specified parameter is a

 

 

 

valid parameter of a configuration set.

 

7-53

Simulink.ConfigSet

 

Name

Description

 

 

“saveAs”

Save a configuration set to a MATLAB file.

 

 

“setPropEnabled”

Prevent or allow a user to change a parameter.

 

 

“set_param”

Set the value of a configuration set parameter.

 

 

 

 

 

Properties

Components

Description

Array of Simulink.ConfigComponent objects representing the components of the configuration set. For example, solver parameters and data import/export parameters.

Data Type array

Access

RW

Description

Description

Description of the configuration set. You can use this property to provide additional information about a configuration set, such as its purpose. This field can remain blank.

Data Type

string

Access

RW

Name

Description

Name of the configuration set. This name represents the configuration set in the Model explorer.

7-54

Simulink.ConfigSet

Data Type string

Access

RW

Methods

attachComponent

Purpose

Attach a component to this configuration set.

Syntax attachComponent(component)

Arguments

component

Instance of Simulink.ConfigComponent class.

Description

This method replaces a component in this configuration set with a component having the same name.

example

The following example replaces the solver component of the active configuration set of model A with the solver component of the active configuration set of model B.

hCs = getActiveConfigSet('B'); hSolverConfig = hCs.getComponent('Solver'); hSolverConfig = hSolverConfig.copy;

hCs = getActiveConfigSet('A'); hCs.attachComponent(hSolverConfig);

copy

Purpose

Create a copy of this configuration set.

Syntax copy

7-55

Simulink.ConfigSet

Description

This method creates a copy of this configuration set.

Note You must use this method to create copies of configuration sets because Simulink.ConfigSet is a handle class. See “Handle Versus Value Classes” for more information.

getComponent

Purpose

Get a component of this configuration set.

Syntax

getComponent(componentName)

Arguments

componentName

String specifying the name of the component to be returned.

Description

Returns the specified component. Omit the argument to get a list of the names of the components that this configuration set contains.

Example

The following code gets the solver component of the active configuration set of the currently selected model.

hCs = getActiveConfigSet(gcs); hSolverConfig = hCs.getComponent('Solver');

The following code displays the names of the components of the currently selected active configuration set of the model at the MATLAB command line.

hCs = getActiveConfigSet(gcs); hCs.getComponent

7-56

Simulink.ConfigSet

getFullName

Purpose

Get the full path of a configuration set.

Syntax

getFullName

Description

This method returns a string specifying the full path of a configuration set, for example, 'vdp/Configuration'.

getModel

Purpose

Get the model that owns this configuration set.

Syntax

getModel

Description

Returns a handle to the model that owns this configuration set.

Example

The following command opens the block diagram of the model that owns the configuration set referenced by the MATLAB workspace variable

hCs.

open_system(hCs.getModel);

get_param

Purpose

Get the value of a configuration set parameter.

Syntax

get_param(paramName)

7-57

Simulink.ConfigSet

Arguments

paramName

String specifying the name of the parameter whose value is to be returned.

Description

This method returns the value of the specified parameter. Specifying paramName as 'ObjectParameters' returns the names of the valid parameters in the configuration set.

Example

The following command gets the name of the solver used by the selected active configuration of the model.

hAcs = getActiveConfigSet(bdroot); hAcs.get_param('SolverName');

Note You can also use the get_param model construction command to get the values of parameters of an active configuration set of a model. For example, get_param(bdroot, 'SolverName') gets the solver name of the currently selected model.

isActive

Purpose

Determine whether configuration set is the active configuration set for the model.

Syntax

isActive

Description

Returns true if this configuration set is the active configuration set of the model that owns this configuration set.

7-58

Simulink.ConfigSet

isValidParam

Purpose

Determine whether a specified parameter is a valid parameter of this configuration set. A parameter is valid if it is compatible with other parameters in the configuration set. For example, if SolverType is

'variable-step', FixedStep is an invalid parameter.

Syntax

isValidParam(paramName)

Arguments

paramName

String specifying the name of the parameter whose validity is to be determined.

Description

This method returns true if the specified parameter is a valid parameter of this configuration set; otherwise, it returns false.

Example

The following code sets the parameter StopTime only if it is a valid parameter of the currently selected active configuration set.

hAcs = getActiveConfigSet(gcs); if hAcs.isValidParam('StopTime')

set_param('StopTime', '20'); end

saveAs

Purpose

Save configuration set to MATLAB file

Syntax

saveAs(fileName)

saveAs(fileName, 'paramName', paramValue)

7-59

Simulink.ConfigSet

Arguments

fileName

String specifying the name of the MATLAB file that the method creates.

paramName, paramValue

Parameter name and value pairs that you optionally use to format the MATLAB file.

 

Name

Value

 

 

'-format'

'MATLAB function'

 

 

 

(default) — Creates a

 

 

 

MATLAB function.

 

 

 

'MATLAB script'

 

 

 

Creates a MATLAB script.

 

 

'-comments'

'on' (default) — The

 

 

 

MATLAB file:

 

 

 

Includes the GUI name

 

 

 

of the parameter as a

 

 

 

comment to help identify

 

 

 

the parameters.

 

 

 

Groups the parameters

 

 

 

by the pane in

 

 

 

the Configuration

 

 

 

Parameters dialog box on

 

 

 

which they are displayed.

 

 

 

'off' — Does not include

 

 

 

comments in the MATLAB

 

 

 

file, so that the file

 

 

 

generates faster.

 

 

'-varname'

'variable' — Any valid

 

 

 

variable name. If you do not

 

 

 

specify this parameter, the

 

 

 

 

 

7-60

Simulink.ConfigSet

Name

Value

 

 

MATLAB script uses cs for the variable.

When you specify '-format', 'MATLAB script', use

'-varname', 'variable' to specify the variable that the script uses for the configuration set object.

When you run the script, the script creates the variable in the base workspace.

Description

saveAs(fileName) saves a configuration set to a MATLAB file. Before saving, you must get a handle to the configuration set. Use fileName to specify the file name.

saveAs(fileName, 'paramName', paramValue) accepts one or more comma-separated parameter name and value pairs. For the valid parameter name and value pairs, see the previous arguments section.

Example

The following code gets the configuration set for sldemo_counters and creates a function called ConfiguredDataFunction.

%Get the active configuration set from sldemo_counters. hCs = getActiveConfigSet('sldemo_counters');

%Save the configuration set as a function. hCs.saveAs('ConfiguredDataFunction');

The following code gets the configuration set for sldemo_counters and creates a script called ConfiguredDataScript. The script uses config_set for the variable name.

% Get the active configuration set from sldemo_counters.

hCs = getActiveConfigSet('sldemo_counters');

7-61

Simulink.ConfigSet

% Save the configuration set as a script.

hCs.saveAs('ConfiguredDataScript', '-format', 'MATLAB script', '-varname', 'config_set');

See Also

getActiveConfigSet, getConfigSet

setPropEnabled

Purpose

Enable a configuration set parameter to be changed.

Syntax

setPropEnabled(paramName, isenabled)

Arguments

paramName

Name of the parameter whose value is to be set.

isenabled

Specify as true to enable parameter; as false, to disable the parameter.

Description

This method sets the enabled status the parameter specified by paramName to the value specified by isenabled. Disabling a parameter prevents the user from changing it.

Example

The following code prevents the user from setting the simulation stop time of the currently selected model.

hAcs = getActiveConfigSet(gcs); hAcs.setPropEnabled('StopTime', false);

set_param

Purpose

Set the value of a configuration set parameter.

7-62

Simulink.ConfigSet

Syntax

set_param(paramName, paramValue)

Arguments

paramName

Name of the parameter whose value is to be set.

paramValue

Value to assign to the parameter.

 

Description

 

This method sets the configuration set parameter specified by

 

paramName to the value specified by paramValue.

 

Example

 

The following command sets the simulation stop time of the selected

 

active configuration set.

 

hAcs = getActiveConfigSet(gcs);

 

hAcs.set_param('StopTime', '20');

 

 

 

Note You can also use the set_param model construction command

 

to set the parameters of the active configuration set. For example,

 

set_param(gcs, 'StopTime', '20') sets the simulation stop time

 

of the currently selected model.

See Also

 

“About Configuration Sets”

7-63

Simulink.ConfigSetRef

Purpose

Description

Property

Summary

Link model to configuration set stored independently of any model

Instances of this handle class allow a model to reference configuration sets that exist outside any model. See “Manage a Configuration Set”, “Overview”, and “Manage a Configuration Reference” for more information.

 

Name

Description

 

 

“Description”

Description of the configuration reference.

 

 

“Name”

Name of the configuration reference.

 

 

“WSVarName”

Name of the workspace variable that

 

 

 

contains the referenced configuration set.

 

Method

Summary

Note You can use the Configuration Reference dialog box to set the Name, Description, and WSVarName properties of a configuration reference. See “Create and Attach a Configuration Reference” for details.

 

Name

Description

 

 

“copy”

Create a copy of a configuration reference.

 

 

“getFullName”

Get the full pathname of a configuration

 

 

 

reference.

 

 

“getModel”

Get the handle of the model that owns a

 

 

 

configuration reference.

 

 

“get_param”

Get the value of a configuration set parameter

 

 

 

indirectly through a configuration reference.

 

 

“getRefConfigSet”

Get the configuration set specified by a

 

 

 

configuration reference.

 

7-64

Simulink.ConfigSetRef

 

Name

Description

 

 

“isActive”

Determine whether a configuration reference

 

 

 

is the active configuration object of the model.

 

 

“refresh”

Update configuration reference after any

 

 

 

change to properties or configuration set

 

 

 

availability.

 

Properties

Description

Description

Description of the configuration reference. You can use this property to provide additional information about a configuration reference, such as its purpose. This field can remain blank.

Data Type

string

Access

RW

Name

Description

Name of the configuration reference. This name represents the configuration reference in the GUI.

Data Type

string

Access

RW

WSVarName

Description

Name of the workspace variable that contains the referenced configuration set.

7-65

Simulink.ConfigSetRef

Data Type

string

Access

RW

Methods

copy

Purpose

Create a copy of this configuration reference.

Syntax

copy

Description

This method creates a copy of this configuration set.

Note You must use this method to create copies of configuration references. This is because Simulink.ConfigSetRef is a handle class. See “Handle Versus Value Classes” for more information.

getFullName

Purpose

Get the full pathname of a configuration reference.

Syntax

getFullName

Description

This method returns a string specifying the full pathname of a configuration reference, e.g., 'vdp/Configuration'.

getModel

Purpose

Get the model that owns this configuration reference.

7-66

Simulink.ConfigSetRef

Syntax

getModel

Description

Returns a handle to the model that owns this configuration reference.

example

The following command opens the block diagram of the model that owns the configuration set referenced by the MATLAB workspace variable

hCr.

open_system(hCr.getModel);

get_param

Purpose

Get the value of a configuration set parameter indirectly through a configuration reference.

Syntax

get_param(paramName)

Arguments

paramName

String specifying the name of the parameter whose value is to be returned.

Description

This method returns the value of the specified parameter from the configuration set to which the configuration reference points. To obtain this value, the method uses the value of WSVarName to retrieve the configuration set, then retrieves the value of paramName from that configuration set. Specifying paramName as 'ObjectParameters' returns the names of all valid parameters in the configuration set. If a valid configuration set is not attached to the configuration reference, the method returns unreliable values.

The inverse method, set_param, is not defined for configuration references. To obtain a parameter value through a configuration reference, you must first use the getRefConfigSet method to retrieve

7-67

Simulink.ConfigSetRef

the configuration set from the reference, then use set_param directly on the configuration set itself.

You can also use the get_param model construction command to get the values of parameters of a model’s active configuration set, e.g., get_param(bdroot, 'SolverName') gets the solver name of the currently selected model.

example

The following command gets the name of the solver used by the selected model’s active configuration.

hAcs = getActiveConfigSet(bdroot); hAcs.get_param('SolverName');

getRefConfigSet

Purpose

Get the configuration set specified by a configuration reference

Syntax

getRefConfigSet

Description

Returns a handle to the configuration set specified by the WSVarName property of a configuration reference.

isActive

Purpose

Determine whether this configuration set is its model’s active configuration set.

Syntax

isActive

Description

Returns true if this configuration set is the active configuration set of the model that owns this configuration set.

7-68

Simulink.ConfigSetRef

refresh

Purpose

Update configuration reference after any change to properties or configuration set availability

Syntax

refresh

Description

Updates a configuration reference after using the API to change any property of the reference, or after providing a configuration set that did not exist at the time the set was originally specified in WSVarName. If you omit executing refresh after any such change, the configuration reference handle will be stale, and using it will give incorrect results.

7-69

Simulink.GlobalDataTransfer

Purpose

Configure concurrent execution data transfers

Description The Simulink.GlobalDataTransfer object contains the data transfer information for the concurrent execution of a model. To access the properties of this class, use the get_param function to get the handle for this class, and then use dot notation to access the properties. For example:

dt=get_param(gcs,'DataTransfer'); dt.DefaultTransitionBetweenContTasks

ans =

Ensure deterministic transfer (minimum delay)

Properties DefaultTransitionBetweenSyncTasks

Global setting for data transfer handling option when the source and destination of a signal are in two different and periodic tasks.

Data Type: Enumeration. Can be one of:

'Ensure data integrity only'

'Ensure deterministic transfer (maximum delay)'

Access: Read/write

DefaultTransitionBetweenContTasks

Global setting for the data transfer handling option for signals that have a continuous sample time.

Data Type: Enumeration. Can be one of:

'Ensure data integrity only'

'Ensure deterministic transfer (maximum delay)'

Access: Read/write

7-70

Simulink.GlobalDataTransfer

DefaultExtrapolationMethodBetweenContTasks

Global setting for the data transfer extrapolation method for signals that have a continuous sample time.

Data Type: Enumeration. Can be one of:

'None'

'Zero Order Hold'

'Linear'

'Quadratic'

Access: Read/write

AutoInsertRateTranBlk

 

Setting for the extrapolation method of data transfer to configure

 

continuous-to-continuous task transitions.

 

Data Type: Boolean. Can be one of:

 

0

 

1

 

Access: Read/write

Copy

Handle. To learn how handle classes affect copy operations, see Copying

Semantics

Objects in the MATLAB Programming Fundamentals documentation.

Examples

Access the properties of this class.

 

dt=get_param(gcs,'DataTransfer');

 

dt.DefaultTransitionBetweenContTasks

 

ans =

 

Ensure deterministic transfer (minimum delay)

7-71

Simulink.GlobalDataTransfer

Alternatives

See Also

How To

“Customize Concurrent Execution Settings”

Simulink.SoftwareTarget.TaskConfiguration

• “Configuring Data Transfer Communications”

7-72

Simulink.MDLInfo

Purpose

Extract model file information without loading block diagram into

 

memory

Description

The class Simulink.MDLInfo extracts information from a model file

 

without loading the block diagram into memory.

 

You can create an MdlInfo object containing all the model information

 

properties, or you can use the static methods for convenient access to

 

individual properties without creating the class first. For example,

 

to get the description only:

 

description = Simulink.MDLInfo.getDescription('mymodel')

 

To get the metadata only:

 

metadata = Simulink.MDLInfo.getMetadata('mymodel')

 

All model information properties are read only.

Construction

info = Simulink.MDLInfo('mymodel') creates an instance of the

 

MdlInfo class info and populates the properties with the information

 

from the model file 'mymodel'.

 

mymodel can be:

 

A block diagram name (for example, vdp)

 

The file name for a file on the MATLAB path (for example,

 

mymodel.slx)

 

A file name relative to the current folder (for example,

 

mydir/mymodel.slx)

 

A fully qualified file name (for example, C:\mydir\mymodel.slx)

 

Simulink.MDLInfo resolves the supplied name by looking at files on the

 

MATLAB path, and ignores any block diagrams in memory. This may

 

cause unexpected results if you supply the name of a loaded model, but

 

its file is shadowed by another file on the MATLAB path. If a file is

7-73

Simulink.MDLInfo

shadowed, you see a warning in the command window. To avoid any confusion, supply a fully-qualified file name to Simulink.MDLInfo.

Properties BlockDiagramName

Name of block diagram.

Description

Description of model.

FileName

Name of model file.

Interface

Names and attributes of the block diagram’s root inports, outports, model references, etc., describing the graphical interface if you created a Model Reference block from this model.

Structure.

IsLibrary

Whether the block diagram is a library.

Metadata

Names and attributes of arbitrary data associated with the model.

Structure. The structure fields can be strings, numeric matrices of type "double", or more structures. Use the method getMetadata to extract this metadata structure without loading the model.

ModelVersion

Model version number.

SimulinkVersion

Version number of Simulink software that was used to save the model file.

7-74

Simulink.MDLInfo

Methods

Copy

Semantics

Examples

getDescription

Extract file description without

 

loading block diagram into

 

memory

getMetadata

Extract file metadata without

 

loading block diagram into

 

memory

Handle. To learn how this affects your use of the class, see Copying Objects in the MATLAB Programming Fundamentals documentation.

Construct and view a model information object:

info = Simulink.MDLInfo('mymodel')

%Get the Version when the model was saved simulink_version = info.SimulinkVersion;

%Get model metadata

metadata = info.metadata

To add metadata to a model, create a metadata structure containing the information you require and use set_param to attach it to the model. For example:

metadata.TestStatus = 'untested'; metadata.ExpectedCompletionDate

= '01/01/2011'; load_system(mymodelname); set_param(mymodelname,'Metadata',...

metadata) % must be a struct save_system(mymodelname); close_system(mymodelname);

Construct a model information object for a model named mpowertrain, in order to find the names of referenced models without loading the model into memory:

7-75

Simulink.MDLInfo

info = Simulink.MDLInfo('mpowertrain') % Get the Interface property info.Interface

Output:

ans =

Inports: [0x1 struct] Outports: [0x1 struct] Trigports: [0x1 struct] Connports: [0x1 struct]

ModelVersion: '1.122' ModelReferences: {2x1 cell}

ParameterArgumentNames: '' TestPointedSignals: [0x1 struct]

Get the referenced models:

info.Interface.ModelReferences

Output is in the form model name / block path | referenced model name:

ans =

'mpowertrain/Model Variants|manual_transmission' 'mpowertrain/engine model|menginemodel'

See Also Simulink.MDLInfo.getDescription; Simulink.MDLInfo.getMetadata

7-76

Simulink.MDLInfo.getDescription

Purpose

Syntax

Description

Examples

See Also

Extract model file description without loading block diagram into memory

description = Simulink.MDLInfo.getDescription('mymodel') description = info.getDescription

description = Simulink.MDLInfo.getDescription('mymodel') returns the description associated with the file mymodel, without loading the model.

mymodel can be:

A block diagram name (for example, vdp)

The file name for a file on the MATLAB path (for example, mymodel.slx)

A file name relative to the current folder (for example, mydir/mymodel.slx)

A fully qualified file name (for example, C:\mydir\mymodel.slx)

description = info.getDescription returns the description property of the Simulink.MDLInfo object info.

Get the description without loading the model or creating a

Simulink.MDLInfo object:

description = Simulink.MDLInfo.getDescription('mymodel')

Create a Simulink.MDLInfo object containing all the model information properties, and get the description property:

info = Simulink.MDLInfo('mymodel') description = info.getDescription

Simulink.MDLInfo; Simulink.MDLInfo.getMetadata

7-77

Simulink.MDLInfo.getMetadata

Purpose

Extract model file metadata without loading block diagram into memory

Syntax

metadata

=

Simulink.MDLInfo.getMetadata('mymodel')

 

metadata

=

info.getMetadata

Description metadata = Simulink.MDLInfo.getMetadata('mymodel') extracts the structure metadata associated with the file mymodel, without loading the model.

mymodel can be:

A block diagram name (for example, vdp)

The file name for a file on the MATLAB path (for example, mymodel.slx)

A file name relative to the current folder (for example, mydir/mymodel.slx)

A fully qualified file name (for example, C:\mydir\mymodel.slx)

metadata = info.getMetadata returns the metadata property of the Simulink.MDLInfo object info.

metadata is a structure containing the names and attributes of arbitrary data associated with the model. The structure fields can be strings, numeric matrices of type "double", or more structures.

To add metadata to a model, create a metadata structure containing the information you require and use set_param to attach it to the model. If it is important to extract the information without loading the model, use metadata instead of adding custom user data with add_param.

Examples Create a metadata structure and use set_param to attach it to the model:

metadata.TestStatus = 'untested'; metadata.ExpectedCompletionDate = '01/01/2011'; load_system('mymodel'); set_param('mymodel','Metadata',metadata) % must be a struct

7-78

Simulink.MDLInfo.getMetadata

save_system('mymodel'); close_system('mymodel');

Get the metadata without loading the model or creating a

Simulink.MDLInfo object:

metadata = Simulink.MDLInfo.getMetadata('mymodel')

Create a Simulink.MDLInfo object containing all the model information properties, and get the metadata property:

info = Simulink.MDLInfo('mymodel') metadata = info.getMetadata

See Also Simulink.MDLInfo; Simulink.MDLInfo.getDescription

7-79

Simulink.ModelAdvisor

Purpose

Description

Run Model Advisor from MATLAB file

Use instances of this class in MATLAB programs to run the Model Advisor, for example, to perform a standard set of checks. MATLAB software creates an instance of this object for each model that you open in the current MATLAB session. To get a handle to a model’s Model Advisor object, execute the following command

ma = Simulink.ModelAdvisor.getModelAdvisor(model);

where model is the name of the model or subsystem that you want to check. Your program can then use the Model Advisor object’s methods to initialize and run the Model Advisor’s checks.

About IDs

Many Simulink.ModelAdvisor object methods require or return IDs. An ID is a string that identifies a Model Advisor check, task, or group. ID must remain constant. A Simulink.ModelAdvisor object includes methods that enable you to retrieve the ID or IDs for all checks, tasks, and groups, checks belonging to groups and tasks, the active check, and selected checks, tasks and groups. See the Simulink.ModelAdvisor “Method Summary” for more information.

You can also determine check IDs as follows:

1In the Model Advisor, select View > Source Tab.

2Navigate to the folder that contains the check.

3In the right pane, click Source. The Model Advisor displays the Title, TitleID, and Source information for each check in the folder.

Syntax

ma = Simulink.ModelAdvisor

7-80

Simulink.ModelAdvisor

Properties

Method

Summary

Arguments

ma

A variable representing the Simulink.ModelAdvisor object you create.

EmitInputParametersToReport

The EmitInputParametersToReport property specifies the display of check input parameters in the Model Advisor report.

 

Value

Description

 

 

'true' (default)

Display check input parameters

 

 

 

in the Model Advisor report.

 

 

'false'

Do not display check input

 

 

 

parameters in the Model Advisor

 

 

 

report.

 

 

Name

Description

 

 

“closeReport”

Close Model Advisor report.

 

 

“deselectCheck”

Clear checks.

 

 

“deselectCheckAll”

Clear all checks.

 

 

“deselectCheckForGroup”

Clear a group of checks.

 

 

“deselectCheckForTask”

Clear checks that belong to a

 

 

 

specified task or set of tasks.

 

 

“deselectTask”

Clear tasks.

 

 

“deselectTaskAll”

Clear all tasks.

 

 

“displayReport”

Display Model Advisor

 

 

 

report.

 

7-81

Simulink.ModelAdvisor

 

Name

Description

 

 

“exportReport”

Copy report to a specified

 

 

 

location.

 

 

“filterResultWithExclusion” on page

Filter objects that have been

 

 

7-89

excluded by user-defined

 

 

 

exclusions.

 

 

“getBaselineMode”

Get baseline mode setting for

 

 

 

the Model Advisor.

 

 

“getCheckAll”

Get the IDs of the checks

 

 

 

performed by the Model

 

 

 

Advisor.

 

 

“getCheckForGroup”

Get checks belonging to a

 

 

 

check group.

 

 

“getCheckForTask”

Get checks belonging to a

 

 

 

task.

 

 

 

 

 

 

“getCheckResult”

Get check results.

 

 

“getCheckResultData”

Get check result data.

 

 

“getCheckResultStatus”

Get pass/fail status of a check

 

 

 

or set of checks.

 

 

“getGroupAll”

Get the IDs of the groups of

 

 

 

tasks performed by the Model

 

 

 

Advisor.

 

 

“getInputParameters” on page 7-94

Get input parameters of a

 

 

 

check.

 

 

“getListViewParameters” on page

Get list view parameters of a

 

 

7-95

check.

 

 

“getModelAdvisor”

Get the Model Advisor for a

 

 

 

model or subsystem.

 

7-82

Simulink.ModelAdvisor

 

Name

Description

 

 

“getSelectedCheck”

Get selected checks.

 

 

“getSelectedSystem” on page 7-97

Get path of system currently

 

 

 

targeted by the Model

 

 

 

Advisor.

 

 

“getSelectedTask”

Get selected tasks.

 

 

“getTaskAll”

Get the IDs of the tasks

 

 

 

performed by the Model

 

 

 

Advisor.

 

 

“Simulink.ModelAdvisor.openConfigUI”

Start the Model Advisor

 

 

on page 7-98

Configuration editor.

 

 

“Simulink.ModelAdvisor.reportexists”

Determine whether a report

 

 

 

exists for a system or

 

 

 

subsystem.

 

 

“runCheck”

Run selected checks.

 

 

“runTask”

Run checks for selected tasks.

 

 

“selectCheck”

Select checks.

 

 

“selectCheckAll”

Select all checks.

 

 

“selectCheckForGroup”

Select a group of checks.

 

 

“selectCheckForTask”

Select checks that belong to a

 

 

 

specified task.

 

 

“selectTask”

Select tasks.

 

 

“selectTaskAll”

Select all tasks.

 

 

“setActionenable” on page 7-103

Set enable/disable status for

 

 

 

a check action.

 

 

“setBaselineMode”

Set baseline mode for the

 

 

 

Model Advisor.

 

 

“setCheckErrorSeverity” on page

Set severity of a check failure.

 

 

7-105

 

 

7-83

Simulink.ModelAdvisor

 

Name

Description

 

 

“setCheckResult”

Set result for the currently

 

 

 

running check.

 

 

“setCheckResultData”

Set result data for the

 

 

 

currently running check.

 

 

“setCheckResultStatus”

Set pass/fail status for the

 

 

 

currently running check.

 

 

“setListViewParameters” on page

Set list view parameters for

 

 

7-108

a check.

 

 

“verifyCheckRan”

Verify that checks have run.

 

 

“verifyCheckResult”

Generate a baseline set of

 

 

 

check results or compare the

 

 

 

current set of results to the

 

 

 

baseline results.

 

 

“verifyCheckResultStatus”

Verify that a model has

 

 

 

passed or failed a set of

 

 

 

checks.

 

 

“verifyHTML”

Generate a baseline report or

 

 

 

compare the current report

 

 

 

to a baseline report.

 

Methods closeReport

Purpose

Close Model Advisor report

Syntax

closeReport

Description

Closes the report associated with this Model Advisor object, which closes the Model Advisor window.

See Also

“displayReport”

7-84

Simulink.ModelAdvisor

deselectCheck

Purpose

Clear check

Syntax

success = deselectCheck(ID)

Arguments

ID

String or cell array that specifies the IDs of the checks to be cleared.

success

True (1) if the check is cleared.

Description

This method clears the checks specified by ID.

Note This method cannot clear disabled checks.

See Also

“getCheckAll”, “deselectCheckForGroup”, “selectCheck”

deselectCheckAll

Purpose

Clear all checks

Syntax

success = deselectCheckAll

Arguments

success

True (1) if all checks are cleared.

Description

Clears all checks that are not disabled.

7-85

Simulink.ModelAdvisor

See Also

“selectCheckAll”

deselectCheckForGroup

Purpose

Clear group of checks

Syntax

success = deselectCheckForGroup(groupName)

Arguments

groupName

String or cell array that specifies the names of the groups to be cleared.

success

True (1) if the method succeeds in clearing the specified group.

Description

Clears a specified group of checks.

See Also

“selectCheckForGroup”

deselectCheckForTask

Purpose

Clear checks that belong to specified task or set of tasks

Syntax

success = deselectCheckForTask(ID)

Arguments

ID

String or cell array of strings that specify the IDs of tasks whose checks are to be cleared.

success

True (1) if the specified tasks are cleared.

Description

Clears checks belonging to the tasks specified by the ID argument.

7-86

Simulink.ModelAdvisor

See Also

“getTaskAll”, “selectCheckForTask”

deselectTask

Purpose

Clear task

Syntax

success = deselectTask(ID)

Arguments

ID

String or cell array that specifies the ID of tasks to be cleared

success

True (1) if the method succeeded in clearing the specified tasks.

Description

Clears the tasks specified by ID.

See Also

“selectTask”, “getTaskAll”

deselectTaskAll

Purpose

Clears all tasks

Syntax

success = deselectTaskAll

Arguments

success

True (1) if this method succeeds in clearing all tasks.

Description

Clears all tasks.

See Also

“selectTaskAll”

7-87

Simulink.ModelAdvisor

displayReport

Purpose

Display report in Model Advisor window

Syntax

displayReport

Description

Displays the report associated with this Model Advisor object in the Model Advisor window. The report includes the most recent results of running checks on the system associated with this Model Advisor object and the current selection status of checks, groups, and tasks for the system.

See Also

“Simulink.ModelAdvisor.reportexists”

exportReport

Purpose

Create copy of report generated by Model Advisor

Syntax

[success message] = exportReport(destination)

Arguments

destination

Path name of copy to be made of the report file.

success

True (1) if this method succeeded in creating a copy of the report at the specified location.

message

Empty if the copy was successful; otherwise, the reason the copy did not succeed.

Description

This method creates a copy of the last report generated by the Model Advisor and stores the copy at the specified location.

7-88

Simulink.ModelAdvisor

See Also

“Simulink.ModelAdvisor.reportexists”

filterResultWithExclusion

Purpose

Filter objects that have been excluded by user-defined exclusions.

Syntax

filteredResultHandles = obj.filterResultWithExclusion(ResultHandles)

Arguments

filteredResultHandles

An array of objects causing exclusion enabled checks to warn or fail.

obj

A variable representing the

Simulink.ModelAdvisor.getModelAdvisor object.

ResultHandles

An array of objects causing a check warning or failure.

Description

This method filters objects that cause a check warning or failure with checks that have exclusions enabled.

Note This method is intended for excluding objects from custom checks created with the Model Advisor’s customization API, a feature available with Simulink Verification and Validation™ .

See Also

“getModelAdvisor” on page 7-96

7-89

Simulink.ModelAdvisor

getBaselineMode

Purpose

Determine whether Model Advisor is in baseline data generation mode

Syntax

mode = getBaselineMode

Arguments

mode

Boolean value indicating baseline mode.

Description

The mode output variable returns true if the Model Advisor is in baseline data mode. Baseline data mode causes the verification methods of the Model Advisor, for example, “verifyHTML”, to generate baseline data.

See Also

“setBaselineMode”, “verifyHTML”, “verifyCheckResult”, “verifyCheckResultStatus”

getCheckAll

Purpose

Get IDs of all checks

Syntax

IDs = getCheckAll

Arguments

IDs

Cell array of strings specifying the IDs of all checks performed by

the Model Advisor.

Description

Returns a cell array of strings specifying the IDs of all checks performed by the Model Advisor.

See Also

“getTaskAll”, “getGroupAll”

7-90

Simulink.ModelAdvisor

getCheckForGroup

Purpose

Get checks that belong to check group

Syntax

IDs = getCheckForTask(groupName)

Arguments

groupName

String specifying the name of a group.

IDs

Cell array of IDs.

Description

Returns a cell array of IDs of the tasks and checks belonging to the group specified by groupName.

See Also

“getCheckForTask”

getCheckForTask

Purpose

Get checks that belong to task

Syntax

checkIDs = getCheckForTask(taskID)

Arguments

taskID

ID of a task.

checkIDs

Cell array of IDs of checks belonging to the specified task.

Description

Returns a cell array of IDs of the checks belonging to the task specified by taskID.

See Also

“getCheckForGroup”

7-91

Simulink.ModelAdvisor

getCheckResult

Purpose

Get results of running check or set of checks

Syntax

result = getCheckResult(ID)

Arguments

ID

ID of a check or cell array of check IDs.

result

A check result or cell array of check results.

Description

Gets results for the specified checks. The format of the results depends on the checks that generated the data.

Note This method is intended for accessing results generated by custom checks created with the Model Advisor’s customization API, an optional feature available with Simulink Verification and Validation software. For more information, see the Simulink Verification and Validation documentation.

See Also

“getCheckResultData”, “getCheckResultStatus”

getCheckResultData

Purpose

Get data resulting from running check or set of checks

Syntax

result = getCheckResultData(ID)

Arguments

ID

Check ID or cell array of check IDs.

7-92

Simulink.ModelAdvisor

result

Data from a check result or cell array of data from check results.

Description

Gets the check result data for the specified checks. The format of the data depends on the checks that generated the data.

Note This method is intended for accessing check result data generated by custom checks created with the Model Advisor’s customization API, an optional feature available with Simulink Verification and Validation software. For more information, see the Simulink Verification and Validation documentation.

See Also

“getCheckResult”, “getCheckResultStatus”

getCheckResultStatus

Purpose

Get status of check or set of checks

Syntax

result = getCheckResultStatus(ID)

Arguments

ID

Check ID or cell array of check IDs.

result

Boolean or a cell array of Boolean values indication the pass or fail status of a check or set of checks.

Description

Invoke this method after running a set of checks to determine whether the checks passed or failed.

See Also

“getCheckResult”, “getCheckResultData”

7-93

Simulink.ModelAdvisor

getGroupAll

Purpose

Get all groups of checks run by Model Advisor

Syntax

IDs = getGroupAll

Arguments

IDs

Cell array of IDs of all groups of checks run by the Model Advisor.

Description

Returns a cell array of IDs of all groups of checks run by the Model Advisor.

See Also

“getCheckAll”, “getTaskAll”

getInputParameters

Purpose

Get input parameters of check

Syntax

params = obj.getInputParameters(check_ID)

Arguments

params

A cell array of ModelAdvisor.InputParameter objects.

obj

A variable representing the Simulink.ModelAdvisor object.

check_ID

A string that uniquely identifies the check.

You can omit the check_ID if you use the method inside a check callback function.

Description

Returns the input parameters associated with a check.

7-94

Simulink.ModelAdvisor

Note This method is intended for accessing custom checks created with the Model Advisor’s customization API, an optional feature available with Simulink Verification and Validation software. For more information, see the Simulink Verification and Validation documentation.

See Also

ModelAdvisor.InputParameter

getListViewParameters

Purpose

Get list view parameters of check

Syntax

params = obj.getListViewParameters(check_ID)

Arguments

params

A cell array of ModelAdvisor.ListViewParameter objects.

obj

A variable representing the Simulink.ModelAdvisor object.

check_ID

A string that uniquely identifies the check.

You can omit the check_ID if you use the method inside a check callback function.

Description

Returns the list view parameters associated with a check.

7-95

Simulink.ModelAdvisor

Note This method is intended for accessing custom checks created with the Model Advisor’s customization API, an optional feature available with Simulink Verification and Validation software. For more information, seethe Simulink Verification and Validation documentation.

See Also

“setListViewParameters” on page 7-108,

ModelAdvisor.ListViewParameter

getModelAdvisor

Purpose

Get Model Advisor object for system or subsystem

Syntax

obj = Simulink.ModelAdvisor.getModelAdvisor(system)

obj = Simulink.ModelAdvisor.getModelAdvisor(system, 'new')

Arguments

system

Name of model or subsystem.

'new'

Required when changing Model Advisor working scope from one system to another without closing the previous session. Alternatively, you can close the previous session before invoking getModelAdvisor, in which case 'new' can be omitted.

obj

Model Advisor object.

Description

This static method (see “Static Methods”) creates and returns an instance of Simulink.ModelAdvisor class for the model or subsystem specified by system.

7-96

Simulink.ModelAdvisor

getSelectedCheck

Purpose

Get currently selected checks

Syntax

IDs = getSelectedCheck

Arguments

IDs

Cell array of IDs of currently selected checks.

Description

Returns the IDs of the currently selected checks in the Model Advisor.

See Also

“getSelectedTask”

getSelectedSystem

Purpose

Get system currently targeted by Model Advisor

Syntax

path = getSelectedSystem

Arguments

path

Path of the selected system.

Description

Gets the path of the system currently targeted by the Model Advisor. That is, the system or subsystem most recently selected for checking either interactively by the user or programmatically via

Simulink.ModelAdisor.getModelAdvisor.

See Also

“getModelAdvisor”

getSelectedTask

Purpose

Get selected tasks

7-97

Simulink.ModelAdvisor

Syntax

IDs = getSelectedTask

Arguments

IDs

Cell array of IDs of currently selected tasks.

Description

Returns the IDs of the currently selected tasks in the Model Advisor.

See Also

“getSelectedCheck”

getTaskAll

Purpose

Get tasks run by Model Advisor

Syntax

IDs = getTaskAll

Arguments

IDs

Cell array of IDs of tasks run by the Model Advisor.

Description

Returns a cell array of IDs of tasks run by the Model Advisor.

See Also

“getCheckAll”, “getGroupAll”

Simulink.ModelAdvisor.openConfigUI

Purpose

Starts Model Advisor Configuration editor

Syntax

Simulink.ModelAdvisor.openConfigUI

Description

This static method starts the Model Advisor Configuration editor. Use the Model Advisor Configuration editor to create customized configurations for the Model Advisor.

7-98

Simulink.ModelAdvisor

Note The Model Advisor Configuration editor is an optional feature available with Simulink Verification and Validation software (see “Organize Checks and Folders Using the Model Advisor Configuration Editor”for more information).

Before starting the Model Advisor Configuration editor, ensure that the current folder is writable. If the folder is not writable, you see an error message when you start the Model Advisor Configuration editor.

The Model Advisor Configuration editor uses the Simulink project (slprj) folder (for more information, see “Model Reference Simulation Targets”) in the current folder to store reports and other information. If this folder does not exist in the current folder, the Model Advisor Configuration editor creates it.

Simulink.ModelAdvisor.reportexists

Purpose

Determine whether report exists for model or subsystem

Syntax

exists = reportexists('system')

Arguments

system

String specifying path of a system or subsystem.

exists

True (1) if a report exists for system.

Description

This method returns true (1) if a report file exists for the model (system) or subsystem specified by system in the slprj/modeladvisor subfolder of the MATLAB working folder.

See Also

“exportReport”

7-99

Simulink.ModelAdvisor

runCheck

Purpose

Run currently selected checks

Syntax

success = runCheck

Arguments

success

True (1) if the checks were run.

Description

Runs the checks currently selected in the Model Advisor. Invoking this method is equivalent to selecting the Run Selected Checks button on the Model Advisor window.

See Also

“selectCheck”

runTask

Purpose

Run currently selected tasks

Syntax

success = runTask

Arguments

success

True (1) if the tasks were run.

Description

Runs the tasks currently selected in the Model Advisor. Invoking this method is equivalent to selecting the Run Selected Checks button on the Model Advisor window.

See Also

“selectTask”

7-100

Simulink.ModelAdvisor

selectCheck

Purpose

Select check

Syntax

success = selectCheck(ID)

Arguments

ID

ID or cell array of IDs of checks to be selected.

success

True (1) if this method succeeded in selecting the specified checks.

Description

Select the check specified by ID. This method cannot select a check that is disabled.

See Also

“selectCheckAll”, “selectCheckForGroup”, “deselectCheck”

selectCheckAll

Purpose

Select all checks

Syntax

success = selectCheckAll

Arguments

success

True (1) if this method succeeded in selecting all checks.

Description

Selects all checks that are not disabled.

See Also

“selectCheck”, “selectCheckForGroup”, “deselectCheck”

selectCheckForGroup

Purpose

Select group of checks

7-101

Simulink.ModelAdvisor

Syntax

success = selectCheckForGroup(ID)

Arguments

ID

ID or cell array of group IDs.

success

True (1) if this method succeeded in selecting the specified groups

Description

Selects the groups specified by ID.

See Also

“deselectCheckForGroup”

selectCheckForTask

Purpose

Select checks that belong to specified task or set of tasks

Syntax

success = selectCheckForTask(ID)

Arguments

ID

ID or cell array of IDs of tasks whose checks are to be selected.

success

True (1) if this method succeeded in selecting the checks for the specified tasks

Description

Selects checks belonging to the tasks specified by the ID argument.

See Also

“deselectCheckForTask”

selectTask

Purpose

Select task

7-102

Simulink.ModelAdvisor

Syntax

success = selectTask(ID)

Arguments

ID

ID or cell array of IDs of the task to be selected.

success

True (1) if this method succeeds in selecting the specified tasks.

Description

Selects a task.

See Also

“deselectTask”

selectTaskAll

Purpose

Select all tasks

Syntax

success = selectTaskAll

Arguments

success

True (1) if this method succeeds in selecting all tasks.

Description

Selects all tasks.

See Also

“deselectTaskAll”

setActionenable

Purpose

Set status for check action

Syntax

obj.setActionenable(value)

7-103

Simulink.ModelAdvisor

Arguments

obj

A variable representing the Simulink.ModelAdvisor object.

value

Boolean value indicating whether the Action box is enabled or disabled.

true — enable the Action box.

false — Disable the Action box.

Description

The setActionenable method specifies the enables or disables the Action box. Only a check callback function can invoke this method.

Note This method is intended for accessing custom checks created with the Model Advisor’s customization API, an optional feature available with Simulink Verification and Validation software. For more information, seethe Simulink Verification and Validation documentation.

See Also

ModelAdvisor.Action

setBaselineMode

Purpose

Set baseline data generation mode for Model Advisor

Syntax

setBaselineMode(mode)

Arguments

mode

Boolean value indicating setting of Model Advisor’s baseline mode, either on (true) or off (false).

7-104

Simulink.ModelAdvisor

Description

Sets the Model Advisor’s baseline mode to mode. Baseline mode causes the Model Advisor’s verify methods to generate baseline comparison data for verifying the results of a Model Advisor run.

See Also

“getBaselineMode”, “verifyCheckResult”, “verifyHTML”

setCheckErrorSeverity

Purpose

Set severity of check failure

Syntax

obj.setCheckErrorSeverity(value)

Arguments

obj

A variable representing the Simulink.ModelAdvisor object.

value

Integer indicating severity of failure.

0 — Check Result = Warning

1 — Check Result = Failed

Description

Sets result status for a currently running check that fails to value. Only a check callback function can invoke this method.

Note This method is intended for accessing custom checks created with the Model Advisor’s customization API, an optional feature available with Simulink Verification and Validation software. For more information, seethe Simulink Verification and Validation documentation.

See Also

“setCheckResultStatus”

7-105

Simulink.ModelAdvisor

setCheckResult

Purpose

Set result for currently running check

Syntax

success = setCheckResult(result)

Arguments

result

String or cell array that specifies the result of the currently running task.

success

True (1) if this method succeeds in setting the check result.

Description

Sets the check result for the currently running check. Only the callback function of a check can invoke this method.

Note This method is intended for use with custom checks created with the Model Advisor’s customization API, an optional feature available with Simulink Verification and Validation software. For more information, seethe Simulink Verification and Validation documentation.

See Also

“getCheckResult”, “setCheckResultData”, “setCheckResultStatus”

setCheckResultData

Purpose

Set result data for currently running check

Syntax

success = setCheckResultData(data)

Arguments

data

Result data to be set.

7-106

Simulink.ModelAdvisor

success

True (1) if this method succeeds in setting the result data for the current check

Description

Sets the check result data for the currently running check. Only the callback function of a check can invoke this method.

Note This method is intended for use with custom checks created with the Model Advisor’s customization API, an optional feature available with Simulink Verification and Validation software. For more information, seethe Simulink Verification and Validation documentation.

See Also

“getCheckResultData”, “setCheckResult”, “setCheckResultStatus”

setCheckResultStatus

Purpose

Set status for currently running check

Syntax

success = setCheckResultStatus(status)

Arguments

status

Boolean value that indicates the status of the check that just ran, either pass (true) or fail (false)

success

True (1) if the status was set.

Description

Sets the pass or fail status for the currently running check to status. Only the callback function of the check can invoke this method.

7-107

Simulink.ModelAdvisor

Note This method is intended for use with custom checks created with the Model Advisor’s customization API, an optional feature available with Simulink Verification and Validation software. For more information, see the Simulink Verification and Validation documentation.

See Also

“getCheckResultStatus”, “setCheckResult”, “setCheckResultData”, “setCheckErrorSeverity” on page 7-105

setListViewParameters

Purpose

Specify list view parameters for check

Syntax

obj.setListViewParameters(check_ID, params)

Arguments

obj

A variable representing the Simulink.ModelAdvisor object.

check_ID

A string that uniquely identifies the check.

You can omit the check_ID if you use the method inside a check callback function.

params

A cell array of ModelAdvisor.ListViewParameter objects.

Description

Set the list view parameters for the check.

7-108

Simulink.ModelAdvisor

Note This method is intended for accessing custom checks created with the Model Advisor’s customization API, an optional feature available with Simulink Verification and Validation software. For more information, seethe Simulink Verification and Validation documentation.

See Also

“getListViewParameters” on page 7-95,

ModelAdvisor.ListViewParameter

verifyCheckRan

Purpose

Verify that Model Advisor has run set of checks

Syntax

[success, missingChecks, additionalChecks] = verifyCheckRan(IDs)

Arguments

IDs

Cell array of IDs of checks to verify.

success

Boolean value specifying whether the checks ran.

missingChecks

Cell array of IDs for specified checks that ran.

additionalChecks

Cell array of IDs for unspecified checks that ran.

Description

The output variable success returns true if all the checks specified by IDs have run. If not, success returns false, missingChecks lists specified checks that did not run. The additionalChecks argument lists unspecified checks that ran.

7-109

Simulink.ModelAdvisor

See Also

“verifyCheckResultStatus”

verifyCheckResult

Purpose

Generate baseline Model Advisor check results file or compare current check results to baseline check results

Syntax

[success message] = verifyCheckResult(baseline, checkIDs)

Arguments

baseline

Path of the baseline check results MAT-file.

checkIDs

Cell array of check IDs.

success

Boolean value specifying whether the method succeeded.

message

String specifying an error message.

Description

If the Model Advisor is in baseline mode (see “setBaselineMode”), this method stores the most recent results of running the checks specified by checkIDs in a MAT-file at the location specified by baseline. If the method is unable to store the check results at the specified location, it returns false in the output variable success and the reason for the failure in the output variable message. If the Model Advisor is not

in baseline mode, this method compares the most recent results of running the checks specified by checkIDs with the report specified by baseline. If the current results match the baseline results, this method returnstrue as the value of the success output variable.

Note You must run the checks specified by checkIDs (see “runCheck”) before invoking verifyCheckResult.

7-110

Simulink.ModelAdvisor

This method enables you to compare the most recent check results generated by the Model Advisor with a baseline set of check results. You can use the method to generate the baseline report as well as perform current-to-baseline result comparisons. To generate a baseline report, put the Model Advisor in baseline mode, using “setBaselineMode”. Then invoke this method with the baseline argument set to the location where you want to store the baseline results. To perform a current-to-baseline report comparison, first ensure that the Model Advisor is not in baseline mode (see “getBaselineMode”). Then invoke this method with the path of the baseline report as the value of the baseline input argument.

See Also

“setBaselineMode”, “getBaselineMode”, “runCheck”, “verifyCheckResultStatus”

verifyCheckResultStatus

Purpose

Verify that model has passed or failed set of checks

Syntax

[success message] = verifyCheckResultStatus(baseline, checkIDs)

Arguments

baseline

Array of Boolean variables.

checkIDs

Cell array of check IDs.

success

Boolean value specifying whether the method succeeded.

message

String specifying an error message.

Description

This method compares the passor fail (true or false) statuses from the most recent running of the checks specified by checkIDs with the Boolean values specified by baseline. If the statuses match the

7-111

Simulink.ModelAdvisor

baseline, this method returns true as the value of the success output variable.

Note You must run the checks specified by checkIDs (see “runCheck”) before invoking verifyCheckResultStatus.

See Also

“runCheck”

verifyHTML

Purpose

Generate baseline Model Advisor report or compare current report to baseline report

Syntax

[success message] = verifyHTML(baseline)

Arguments

baseline

Path of a Model Advisor report.

success

Boolean value specifying whether the method succeeded.

message

String specifying an error message.

Description

If the Model Advisor is in baseline mode (see “setBaselineMode”), this method stores the report most recently generated by the Model Advisor at the location specified by baseline. If the method is unable to store a copy of the report at the specified location, it returns false in the output variable success and the reason for the failure in the output variable message. If the Model Advisor is not in baseline mode, this method compares the report most recently generated by the Model Advisor with the report specified by baseline. If the current report has

7-112

Simulink.ModelAdvisor

exactly the same content as the baseline report, this method returns true as the value of the success output variable.

This method enables you to compare a report generated by the Model Advisor with a baseline report to determine if they differ. You can use the method to generate the baseline report as well as perform current-to-baseline report comparisons. To generate a baseline report, put the Model Advisor in baseline mode. Then invoke this method with the baseline argument set to the location where you want to store the baseline report. To perform a current-to-baseline report comparison, first ensure that the Model Advisor is not in baseline mode (see “getBaselineMode”). The invoke this method with the path of the baseline report as the value of the baseline input argument.

See Also

“setBaselineMode”, “getBaselineMode”, “verifyCheckResult”

7-113

Simulink.ModelDataLogs

Purpose

Container for model’s signal data logs

Description

Note The ModelDataLogs format is supported for backwards compatibility. The ModelDataLogs format will be removed in a future release. For an existing model that uses the ModelDataLogs format, you should migrate the model to use Dataset format. For details, see “ Migrate from ModelDataLogs to Dataset Format”.

For new models, use the Dataset logging format, which stores logged data in Simulink.SimulationData.Dataset objects.

If you set Configuration Parameters > Data Import/Export > Signal logging format to ModelDataLogs, Simulink software creates instances of the Simulink.ModelDataLogs class to contain signal logs that it creates while simulating a model (see “Signal Logging”). In particular, Simulink software creates an instance of this class for a top model and for each model referenced by the top model that contains signals to be logged. Simulink software assigns the ModelDataLogs object for the top model to a variable in the MATLAB workspace. The name of the variable is the name specified in the Signal logging name field on the Data Import/export pane of the model’s Configuration Parameters dialog box. The default value is logsout.

A ModelDataLogs object has a variable number of properties. The first property, named Name, specifies the name of the model whose signal data the object contains or, if the model is a referenced model, the name of the Model block that references the model. The remaining properties reference objects that contain signal data logged during simulation of the model. The objects may be instances of any of the following types of objects:

Simulink.ModelDataLogs

Container for the data logs of a model

Simulink.SubsysDataLogs

7-114

Simulink.ModelDataLogs

Container for the data logs of a subsystem

Simulink.ScopeDataLogs

Container for the data logs of Scope signal viewers

Simulink.Timeseries

Data log for any signal except a mux or bus signal

Simulink.TsArray

Data log for a mux or bus signal

The names of the properties identify the data being logged as follows:

For signal data logs, the name of the signal

For a subsystem or model log container, the name of the subsystem or model, respectively

For a scope viewer data log, the name specified on the viewer’s parameter dialog box

Note If a name contains spaces, the ModelDataLogs objects specifies its name as ('name') where name is the actual name, e.g., ('Brake Subsystem'). See “Handling Spaces and Newlines in Logged Names” for more information.

Consider, for example, the following model.

7-115

Simulink.ModelDataLogs

As indicated by the testpoint icons, this model specifies that Simulink software should log the signals named step and scope in the model’s root system and the signal named clk in the subsystem named Delayed Out. After simulation of this model, the MATLAB workspace contains the following variable:

>> logsout

 

 

logsout =

 

 

Simulink.ModelDataLogs (siglgex):

 

Name

elements

Simulink Class

scope

2

TsArray

step

1

Timeseries

('Delayed Out')

2

SubsysDataLogs

7-116

Simulink.ModelDataLogs

The logsout variable contains the signal data logged during the simulation. You can use fully qualified object names or the Simulink unpack command to access the signal data stored in logsout. For example, to access the amplitudes of the clk signal in the Delayed Out subsystem, enter

>> data = logsout.('Delayed Out').clk.Data;

or

>>logsout.unpack('all');

>>data = clk.Data;

You can use a custom logging name or signal name when logging a signal. If you use the signal name, and that name occupies more than one line, include an sprintf('\n') between the lines of the signal name when accessing the logged data. For example, to access the signal in the following model:

Use the following syntax:

logsout.(['scope' sprintf('\n') '(delayed out)'])

See “Handling Spaces and Newlines in Logged Names” for more information.

See Also “Signal Logging”, Simulink.SubsysDataLogs, Simulink.ScopeDataLogs, Simulink.Timeseries, Simulink.TsArray, who, whos, unpack

7-117

Simulink.SimState.ModelSimState

Purpose

Description

Properties

Methods

Access SimState snapshot data

The Simulink.SimState.ModelSimState class contains all of the information associated with a “snapshot” of a simulation, including the logged states, the time of the snapshot, and the start time of the simulation. To access these data for a block, use the getBlockSimState method or the loggedStates property.

description

Specify a description. By default, Simulink software generates a string based on your model name.

loggedStates

The logged states are the continuous and discrete states of the blocks in a model. These states represent a subset of the complete simulation state (SimState) of the model.

Attributes:

dependent

snapshotTime

Time at which Simulink software takes a “snapshot” of the complete simulation states. This data is read only.

startTime

Time at which the simulation starts. This data is read only.

getBlockSimState

Access SimState of individual

 

Stateflow Chart, MATLAB

 

Function, or S-function block

setBlockSimState

Set SimState of individual

 

Stateflow Chart, MATLAB

 

Function, or S-function block

7-118

Simulink.SimState.ModelSimState

Copy

Value. To learn how value classes affect copy operations, see Copying

Semantics

Objects in the MATLAB Programming Fundamentals documentation.

7-119

Simulink.ModelManagement.Project.CurrentProject

Purpose

Manipulate the currently open Simulink project from the command line

Description

Use an instance of

 

 

Simulink.ModelManagement.Project.CurrentProject class

 

to perform the following operations.

 

 

Open and close Simulink projects

 

 

Investigate the properties of the currently open Simulink project

 

Change some properties of the currently open Simulink project

Construction

Create an instance of the class as follows.

 

p = Simulink.ModelManagement.Project.CurrentProject();

Methods

addFileToProject

Add a file to the currently open

 

 

Simulink project

 

attachLabelToFile

Add a label to a file in the

 

 

currently open Simulink project

 

close

Close the currently open Simulink

 

 

project

 

createCategory

Create a category in the currently

 

 

open Simulink project

 

createLabel

Create a label in a category in the

 

 

currently open Simulink project

 

detachLabelFromFile

Remove a label from a file in the

 

 

currently open Simulink project

 

export

Export Simulink project to Zip file

7-120

Simulink.ModelManagement.Project.CurrentProject

getAttachedLabels

Get a list of labels attached

 

to a file in the currently open

 

Simulink project

getCategories

Get a list of the categories of

 

file labels in the currently open

 

Simulink project

getFilesInProject

Get a list of files in the currently

 

open Simulink project

getLabels

Get a list of labels in a category

 

in the currently open Simulink

 

project

getProjectName

Get the name of the currently

 

open Simulink project

getRootDirectory

Get the name of the root folder

 

for the currently open Simulink

 

project

getRootFolder

Get the name of the root folder

 

for the currently open Simulink

 

project

isProjectLoaded

Return true when a Simulink

 

project is loaded and false when

 

no project is loaded

loadProject

Load an existing Simulink project

 

and close any currently open

 

project

removeCategory

Remove a category from the

 

currently open Simulink project

removeFileFromProject

Remove a file from the currently

 

open Simulink project

7-121

Simulink.ModelManagement.Project.CurrentProject

Examples

How To

removeLabel

Remove a label from a category

 

in the currently open Simulink

 

project

setProjectName

Change the name of the currently

 

open Simulink project

This example creates a new instance of the

Simulink.ModelManagement.Project.CurrentProject class.

p = Simulink.ModelManagement.Project.CurrentProject();

• “Simulink Projects”

7-122

Simulink.ModelWorkspace

Purpose

Description

Property

Summary

Method

Summary

Describe model workspace

Instances of this class describe model workspaces. Simulink software creates an instance of this class for each model that you open during a Simulink session. See “Model Workspaces” for more information.

 

Name

Access

 

Description

 

 

DataSource

RW

 

Specifies the source used to initialize this

 

 

 

 

 

workspace. Valid values are

 

 

 

 

 

'Model File'

 

 

 

 

 

'MAT-File'

 

 

 

 

 

'MATLAB Code'

 

 

 

 

 

'MATLAB File'

 

 

 

 

 

 

 

 

FileName

RW

 

Specifies the name of the MAT-file

 

 

 

 

 

used to initialize this workspace.

 

 

 

 

 

Simulink software ignores this property

 

 

 

 

 

if DataSource is neither 'MAT-File' nor

 

 

 

 

 

'MATLAB Code'.

 

 

MATLABCode

RW

 

A string specifying MATLAB code used

 

 

 

 

 

to initialize this workspace. Simulink

 

 

 

 

 

software ignores this property if

 

 

 

 

 

DataSource is not 'MATLAB Code'.

 

 

 

 

 

 

 

Name

 

Description

 

 

“assignin”

 

Assign a value to a variable in the model’s

 

 

 

 

workspace.

 

 

“clear”

 

Clear the model’s workspace.

 

 

 

 

 

 

 

7-123

Simulink.ModelWorkspace

 

Name

Description

 

 

“evalin”

Evaluate an expression in the model’s

 

 

 

workspace.

 

 

“reload”

Reload the model workspace from the

 

 

 

workspace’s data source.

 

 

“save”

Save the model’s workspace to a specified

 

 

 

MAT-file.

 

 

“saveToSource”

Save the workspace to the MAT-file that the

 

 

 

workspace designates as its data source.

 

 

“whos”

List the variables in the model workspace.

 

 

 

 

 

Methods

assignin

Purpose

Assign a value to a variable in the model’s workspace.

Syntax

assignin('varname', varvalue)

Arguments

varname

Name of the variable to be assigned a value.

varvalue

Value to be assigned the variable.

Description

This method assigns the value specified by varvalue to the variable whose name is varname.

See also

“evalin”

7-124

Simulink.ModelWorkspace

clear

Purpose

Clear the model’s workspace.

Syntax clear

Description

This method empties the workspace of its variables.

evalin

Purpose

Evaluate an expression in the model’s workspace.

Syntax evalin('expression')

Arguments

expression

A MATLAB expression to be evaluated.

Description

This method evaluates expression in the model workspace.

See also

“assignin”

reload

Purpose

Reload the model workspace from the workspace’s data source.

Syntax reload

Description

This method reloads the model workspace from the data source specified by its DataSource parameter. The data source must be 'MAT-File',

'MATLAB Code', or 'MATLAB File' .

7-125

Simulink.ModelWorkspace

See also

“saveToSource”

save

Purpose

Save the model’s workspace to a specified MAT-file.

Syntax

save('filename')

Arguments

filename

Name of a MAT-file.

Description

This method saves the model’s workspace to the MAT-file specified by filename.

Note This method allows you to save the workspace to a file other than the file specified by the workspace’s FileName property. If you want to save the model workspace to the file specified by the file’s FileName property, it is simpler to use the workspace’s saveToSource method.

example

hws = get_param('mymodel','modelworkspace') hws.DataSource = 'MAT-File';

hws.FileName = 'workspace'; hws.assignin('roll', 30); hws.saveToSource; hws.assignin('roll', 40); hws.save('workspace_test.mat');

See also

“reload”, “saveToSource”

7-126

Simulink.ModelWorkspace

saveToSource

Purpose

Save the workspace to the MAT-file that it designates as its data source.

Syntax

saveToSource

Description

This method saves the model workspace designated by its FileName property.

example

hws = get_param('mymodel','modelworkspace') hws.DataSource = 'MAT-File';

hws.FileName = 'params'; hws.assignin('roll', 30); hws.saveToSource;

See also

“save”, “reload”

whos

Purpose

List the variables in the model workspace.

Syntax

whos

Description

This method lists the variables in the model’s workspace. The listing includes the size and class of the variables.

7-127

Simulink.ModelWorkspace

example

>>hws = get_param('mymodel','modelworkspace');

>>hws.assignin('k', 2);

>>hws.whos

Name

Size

Bytes

Class

k

1x1

8

double array

7-128

Simulink.MSFcnRunTimeBlock

Purpose

Get run-time information about Level-2 MATLAB S-function block

Description

This class allows a Level-2 MATLAB S-function or other MATLAB

 

program to obtain information from Simulink software and provide

 

information to Simulink software about a Level-2 MATLAB S-Function

 

block. Simulink software creates an instance of this class for each

 

Level-2 MATLAB S-Function block in a model. Simulink software

 

passes the object to the callback methods of Level-2 MATLAB

 

S-functions when it updates or simulates a model, allowing the

 

callback methods to get and provide block-related information to

 

Simulink software. See “Write Level-2 MATLAB S-Functions” for more

 

information.

 

You can also use instances of this class in MATLAB programs to

 

obtain information about Level-2 MATLAB S-Function blocks during

 

a simulation. See “Access Block Data During Simulation” for more

 

information.

 

The Level-2 MATLAB S-function template

 

matlabroot/toolbox/simulink/blocks/msfuntmpl.m shows how to

 

use a number of the following methods.

Parent

Simulink.RunTimeBlock

Class

 

Derived

None

Classes

 

7-129

Simulink.MSFcnRunTimeBlock

Property

Summary

Method

Summary

 

Name

Description

 

 

“AllowSignalsWithMoreThan2D”

enable Level-2 MATLAB

 

 

 

S-function to use

 

 

 

multidimensional signals.

 

 

“DialogPrmsTunable”

Specifies which of the

 

 

 

S-function’s dialog

 

 

 

parameters are tunable.

 

 

“NextTimeHit”

Time of the next sample hit

 

 

 

for variable sample time

 

 

 

S-functions.

 

 

Name

Description

 

 

“AutoRegRuntimePrms”

Register this block’s

 

 

 

dialog parameters as

 

 

 

run-time parameters.

 

 

“AutoUpdateRuntimePrms”

Update this block’s

 

 

 

run-time parameters.

 

 

“IsDoingConstantOutput”

Determine whether

 

 

 

the current simulation

 

 

 

stage is the constant

 

 

 

sample time stage.

 

 

“IsMajorTimeStep”

Determine whether

 

 

 

the current simulation

 

 

 

time step is a major

 

 

 

time step.

 

 

“IsSampleHit”

Determine whether the

 

 

 

current simulation time

 

 

 

is one at which a task

 

 

 

handled by this block is

 

 

 

active.

 

7-130

Simulink.MSFcnRunTimeBlock

 

Name

Description

 

 

“IsSpecialSampleHit”

Determine whether the

 

 

 

current simulation time

 

 

 

is one at which multiple

 

 

 

tasks handled by this

 

 

 

block are active.

 

 

“RegBlockMethod”

Register a callback

 

 

 

method for this block.

 

 

“RegisterDataTypeFxpBinaryPoint”

Register fixed-point

 

 

 

data type with binary

 

 

 

point-only scaling.

 

 

“RegisterDataTypeFxpFSlopeFixexpBias”

Register fixed-point

 

 

 

data type with [Slope

 

 

 

Bias] scaling specified

 

 

 

in terms of fractional

 

 

 

slope, fixed exponent,

 

 

 

and bias.

 

 

“RegisterDataTypeFxpSlopeBias”

Register data type with

 

 

 

[Slope Bias] scaling.

 

 

“SetAccelRunOnTLC”

Specify whether to

 

 

 

use this block’s TLC

 

 

 

file to generate the

 

 

 

simulation target for

 

 

 

the model that uses it.

 

 

“SetPreCompInpPortInfoToDynamic”

Set precompiled

 

 

 

attributes of this

 

 

 

block’s input ports

 

 

 

to be inherited.

 

 

“SetPreCompOutPortInfoToDynamic”

Set precompiled

 

 

 

attributes of this

 

 

 

block’s output ports

 

 

 

to be inherited.

 

7-131

Simulink.MSFcnRunTimeBlock

 

Name

Description

 

 

“SetPreCompPortInfoToDefaults”

Set precompiled

 

 

 

attributes of this

 

 

 

block’s ports to the

 

 

 

default values.

 

 

“SetSimViewingDevice”

Specify whether block

 

 

 

is a viewer.

 

 

“SupportsMultipleExecInstances”

 

 

 

“WriteRTWParam”

Write custom

 

 

 

parameter information

 

 

 

to Simulink Coder file.

 

Properties

AllowSignalsWithMoreThan2D

Description

Allow Level-2 MATLAB S-functions to use multidimensional signals. You must set the AllowSignalsWithMoreThan2D property in the setup method.

Data Type

Boolean

Access

RW

DialogPrmsTunable

Description

Specifies whether a dialog parameter of the S-function is tunable. Tunable parameters are registered as run-time parameters when you call the “AutoRegRuntimePrms” method. Note that SimOnlyTunable parameters are not registered as run-time parameters. For example, the following lines initializes three dialog parameters where the first is tunable, the second in not tunable, and the third is tunable only during simulation.

7-132

Simulink.MSFcnRunTimeBlock

block.NumDialogPrms

= 3;

block.DialogPrmsTunable = {'Tunable','Nontunable','SimOnlyTunable'};

Data Type array

Access

RW

NextTimeHit

Description

Time of the next sample hit for variable sample-time S-functions.

Data Type double

Access

RW

Methods

AutoRegRuntimePrms

Purpose

Register a block’s tunable dialog parameters as run-time parameters.

Syntax

AutoRegRuntimePrms;

Description

Use in the PostPropagationSetup method to register this block’s tunable dialog parameters as run-time parameters.

AutoUpdateRuntimePrms

Purpose

Update a block’s run-time parameters.

Syntax

AutoRegRuntimePrms;

7-133

Simulink.MSFcnRunTimeBlock

Description

Automatically update the values of the run-time parameters during a call to ProcessParameters.

See the S-function matlabrootadapt_lms.m in the Simulink model sldemo_msfcn_lms for an example.

IsDoingConstantOutput

Purpose

Determine whether this is in the constant sample time stage of a simulation.

Syntax

bVal = IsDoingConstantOutput;

Description

Returns true if this is the constant sample time stage of a simulation, i.e., the stage at the beginning of a simulation where Simulink software computes the values of block outputs that cannot change during the simulation (see “Constant Sample Time”). Use this method in the Outputs method of an S-function with port-based sample times to avoid unnecessarily computing the outputs of ports that have constant sample time, i.e., [inf, 0].

function Outputs(block)

.

.

if block.IsDoingConstantOutput

ts = block.OutputPort(1).SampleTime; if ts(1) == Inf

%% Compute port's output. end

end

.

.

%% end of Outputs

See “Specifying Port-Based Sample Times” for more information.

7-134

Simulink.MSFcnRunTimeBlock

IsMajorTimeStep

Purpose.

Determine whether current time step is a major or a minor time step.

Syntax

bVal = IsMajorTimeStep;

Description

Returns true if the current time step is a major time step; false, if it is a minor time step. This method can be called only from the Outputs or Update methods.

IsSampleHit

Purpose

Determine whether the current simulation time is one at which a task handled by this block is active.

Syntax

bVal = IsSampleHit(stIdx);

Arguments

stIdx

Global index of the sample time to be queried.

Description

Use in Outputs or Update block methods when the MATLAB S-function has multiple sample times to determine whether a sample hit has occurred at stIdx. The sample time index stIdx is a global index for the Simulink model. For example, consider a model that contains three sample rates of 0.1, 0.2, and 0.5, and a MATLAB S-function block that contains two rates of 0.2 and 0.5. In the MATLAB S-function, block.IsSampleHit(0) returns true for the rate 0.1, not the rate 0.2.

This block method is similar to ssIsSampleHit for C-MeX S-functions, however ssIsSampleHit returns values based on only the sample times contained in the S-function. For example, if the model described

7-135

Simulink.MSFcnRunTimeBlock

above contained a C-MeX S-function with sample rates of 0.2 and 0.5, ssIsSampleHit(S,0,tid) returns true for the rate of 0.2.

Use port-based sample times to avoid using the global sample time index for multi-rate systems (see Simulink.BlockPortData).

IsSpecialSampleHit

Purpose

Determine whether the current simulation time is one at which multiple tasks implemented by this block are active.

Syntax

bVal = IsSpecialSampleHit(stIdx1,stIdx1);

Arguments

stIdx1

Index of sample time of first task to be queried.

stIdx2

Index of sample time of second task to be queried.

Description

Use in Outputs or Update block methods to ensure the validity of data shared by multiple tasks running at different rates. Returns true if a sample hit has occurred at stIdx1 and a sample hit has also occurred at stIdx2 in the same time step (similar to ssIsSpecialSampleHit for C-Mex S-functions).

RegBlockMethod

Purpose

Register a block callback method.

Syntax

RegBlockMethod(methName, methHandle);

Arguments

methName

Name of method to be registered.

7-136

Simulink.MSFcnRunTimeBlock

methHandle

MATLAB function handle of the callback method to be registered.

Description

Registers the block callback method specified by methName and methHandle. Use this method in the setup function of a Level-2 MATLAB S-function to specify the block callback methods that the S-function implements.

RegisterDataTypeFxpBinaryPoint

Purpose

Register fixed-point data type with binary point-only scaling.

Syntax

dtID = RegisterDataTypeFxpBinaryPoint(isSigned, wordLength, fractionalLength, obeyDataTypeOverride);

Arguments

isSigned

true if the data type is signed.

false if the data type is unsigned.

wordLength

Total number of bits in the data type, including any sign bit.

fractionalLength

Number of bits in the data type to the right of the binary point.

obeyDataTypeOverride

true indicates that the Data Type Override setting for the subsystem is to be obeyed. Depending on the value of Data Type Override, the resulting data type could be True Doubles, True Singles, ScaledDouble, or the fixed-point data type specified by the other arguments of the function.

false indicates that the Data Type Override setting is to be ignored.

7-137

Simulink.MSFcnRunTimeBlock

Description

This method registers a fixed-point data type with Simulink software and returns a data type ID. The data type ID can be used to specify the data types of input and output ports, run-time parameters, and DWork states. It can also be used with all the standard data type access methods defined for instances of this class, such as “DatatypeSize”.

Use this function if you want to register a fixed-point data type with binary point-only scaling. Alternatively, you can use one of the other fixed-point registration functions:

Use “RegisterDataTypeFxpFSlopeFixexpBias” to register a data type with [Slope Bias] scaling by specifying the word length, fractional slope, fixed exponent, and bias.

Use “RegisterDataTypeFxpSlopeBias” to register a data type with [Slope Bias] scaling.

If the registered data type is not one of the Simulink built-in data types, a Simulink Fixed Point license is checked out.

RegisterDataTypeFxpFSlopeFixexpBias

Purpose

Register fixed-point data type with [Slope Bias] scaling specified in terms of fractional slope, fixed exponent, and bias

Syntax

dtID = RegisterDataTypeFxpFSlopeFixexpBias(isSigned, wordLength, fractionalSlope, fixedexponent, bias, obeyDataTypeOverride);

Arguments

isSigned

true if the data type is signed.

false if the data type is unsigned.

wordLength

Total number of bits in the data type, including any sign bit.

7-138

Simulink.MSFcnRunTimeBlock

fractionalSlope

Fractional slope of the data type.

fixedexponent

exponent of the slope of the data type.

bias

Bias of the scaling of the data type.

obeyDataTypeOverride

true indicates that the Data Type Override setting for the subsystem is to be obeyed. Depending on the value of Data Type Override, the resulting data type could be True Doubles, True Singles, ScaledDouble, or the fixed-point data type specified by the other arguments of the function.

false indicates that the Data Type Override setting is to be ignored.

Description

This method registers a fixed-point data type with Simulink software and returns a data type ID. The data type ID can be used to specify the data types of input and output ports, run-time parameters, and DWork states. It can also be used with all the standard data type access methods defined for instances of this class, such as “DatatypeSize”.

Use this function if you want to register a fixed-point data type by specifying the word length, fractional slope, fixed exponent, and bias. Alternatively, you can use one of the other fixed-point registration functions:

Use “RegisterDataTypeFxpBinaryPoint” to register a data type with binary point-only scaling.

Use “RegisterDataTypeFxpSlopeBias” to register a data type with [Slope Bias] scaling.

If the registered data type is not one of the Simulink built-in data types, a Simulink Fixed Point license is checked out.

7-139

Simulink.MSFcnRunTimeBlock

RegisterDataTypeFxpSlopeBias

Purpose

Register data type with [Slope Bias] scaling.

Syntax

dtID = RegisterDataTypeFxpSlopeBias(isSigned, wordLength, totalSlope, bias, obeyDataTypeOverride);

Arguments

isSigned

true if the data type is signed.

false if the data type is unsigned.

wordLength

Total number of bits in the data type, including any sign bit.

totalSlope

Total slope of the scaling of the data type.

bias

Bias of the scaling of the data type.

obeyDataTypeOverride

true indicates that the Data Type Override setting for the subsystem is to be obeyed. Depending on the value of Data Type Override, the resulting data type could be True Doubles, True Singles, ScaledDouble, or the fixed-point data type specified by the other arguments of the function.

false indicates that the Data Type Override setting is to be ignored.

Description

This method registers a fixed-point data type with Simulink software and returns a data type ID. The data type ID can be used to specify the data types of input and output ports, run-time parameters, and DWork states. It can also be used with all the standard data type access

7-140

Simulink.MSFcnRunTimeBlock

methods defined for instances of this class, such as “DatatypeSize” on page 7-174.

Use this function if you want to register a fixed-point data type with [Slope Bias] scaling. Alternatively, you can use one of the other fixed-point registration functions:

Use “RegisterDataTypeFxpBinaryPoint” to register a data type with binary point-only scaling.

Use “RegisterDataTypeFxpFSlopeFixexpBias” to register a data type by specifying the word length, fractional slope, fixed exponent, and bias

If the registered data type is not one of the Simulink built-in data types, a Simulink Fixed Point license is checked out.

SetAccelRunOnTLC

Purpose

Specify whether to use block’s TLC file to generate code for the Accelerator mode of Simulink software.

Syntax

SetAccelRunOnTLC(bVal);

Arguments

bVal

May be 'true' (use TLC file) or 'false' (run block in interpreted mode).

Description

Specify if the block should use its TLC file to generate code that runs with the accelerator. If this option is 'false', the block runs in interpreted mode. See the S-function

matlabroot/toolbox/simulink/blocks/msfcn_times_two.m in the Simulink model msfcndemo_timestwo for an example.

7-141

Simulink.MSFcnRunTimeBlock

SetPreCompInpPortInfoToDynamic

Purpose

Set precompiled attributes of this block’s input ports to be inherited.

Syntax

SetPreCompInpPortInfoToDynamic;

Description

Initialize the compiled information (dimensions, data type, complexity, and sampling mode) of this block’s input ports to be inherited. See the

S-function matlabroot/toolbox/simulink/simdemos/adapt_lms.m in the Simulink model sldemo_msfcn_lms for an example.

SetPreCompOutPortInfoToDynamic

Purpose

Set precompiled attributes of this block’s output ports to be inherited.

Syntax

SetPreCompOutPortInfoToDynamic;

Description

Initialize the compiled information (dimensions, data type, complexity, and sampling mode) of the block’s output ports to be inherited. See the

S-function matlabroot/toolbox/simulink/simdemos/adapt_lms.m in the Simulink model sldemo_msfcn_lms for an example.

SetPreCompPortInfoToDefaults

Purpose

Set precompiled attributes of this block’s ports to the default values.

Syntax

SetPreCompPortInfoToDefaults;

Description

Initialize the compiled information (dimensions, data type, complexity, and sampling mode) of the block’s ports to the default values. By default, a port accepts a real scalar sampled signal with a data type of double.

7-142

Simulink.MSFcnRunTimeBlock

SetSimViewingDevice

Purpose

Specify whether this block is a viewer.

Syntax

SetSimViewingDevice(bVal);

Arguments

bVal

May be 'true' (is a viewer) or 'false' (is not a viewer).

Description

Specify if the block is a viewer/scope. If this flag is specified, the block will be used only during simulation and automatically stubbed out in generated code.

SupportsMultipleExecInstances

Purpose

Specify whether or not a For Each Subsystem supports an S-function inside of it.

Syntax

SupportsMultipleExecInstances(bVal);

Arguments

bVal

May be 'true' (S-function is supported) or 'false' (S-function is not supported).

Description

Specify if an S-function can operate within a For Each Subsystem.

WriteRTWParam

Purpose

Write a custom parameter to the Simulink Coder information file used for code generation.

7-143

Simulink.MSFcnRunTimeBlock

Syntax

WriteRTWParam(pType, pName, pVal)

Arguments

pType

Type of the parameter to be written. Valid values are 'string' and 'matrix'.

pName

Name of the parameter to be written.

pVal

Value of the parameter to be written.

Description

Use in the WriteRTW method of the MATLAB S-function to write out custom parameters. These parameters are generally settings used to determine how code should be

generated in the TLC file for the S-function. See the S-function

matlabroot/toolbox/simulink/simdemos/adapt_lms.m in the Simulink model sldemo_msfcn_lms for an example.

7-144

Simulink.NumericType

Purpose

Specify data type

Description This class lets you specify a data type as follows:

1Create an instance of this class in the MATLAB base workspace or a model workspace. To create a numeric type in a model workspace, you must disable the Is alias option.

2Set object properties to the properties of the custom data type.

3Assign the data type to all signals and parameters of your model that you want to conform to the data type.

Assigning a data type in this way allows you to change the data types of the signals and parameters in your model by changing the properties of the object that describe them. You do not have to change the model itself.

7-145

Simulink.NumericType

Property

Dialog

Box

Data type mode

Data type of this numeric type. The options are

 

Option

Description

 

 

Boolean

Same as the MATLAB boolean type.

 

 

Double

Same as the MATLAB double type.

 

 

Single

Same as the MATLAB single type.

 

 

 

 

 

7-146

Simulink.NumericType

 

Option

Description

 

 

Fixed-point:

A fixed-point data type with unspecified

 

 

unspecified

scaling.

 

 

scaling

 

 

 

Fixed-point:

A fixed-point data type with binary-point

 

 

binary point

scaling.

 

 

scaling

 

 

 

Fixed-point:

A fixed-point data type with slope and

 

 

slope and bias

bias scaling.

 

 

scaling

 

 

 

 

 

 

Selecting a data type mode causes Simulink software to enable controls on the dialog box (see below) that apply to the mode and to disable other controls that do not apply. Selecting a fixed-point data type mode might, depending on the other dialog box options that you select, cause the model to run only on systems that have a Simulink Fixed Point option installed.

Data type override

Data type override setting for this numeric type. The options are

 

Option

Description

 

 

Inherit (default)

Data type override setting

 

 

 

for the context in which this

 

 

 

numeric type is used (block,

 

 

 

signal, Stateflow chart in

 

 

 

Simulink) applies to this

 

 

 

numeric type.

 

 

Off

Data type override setting does

 

 

 

not affect this numeric type.

 

Is alias

If this option is selected for a workspace object of this type, Simulink software uses the name of the object as the data type for all objects that specify the object as its data type. Otherwise,

7-147

Simulink.NumericType

Simulink software uses the data type mode of the data type as its name, or, if the data type mode is a fixed-point mode, Simulink software generates a name that encodes the type’s properties, using the encoding specified by the Simulink Fixed Point product.

Data scope

Specifies whether the data type definition should be imported from, or exported to, a header file during code generation. The possible values are:

 

Value

Action

 

 

Auto (default)

If no value is specified for Header file, export

 

 

 

the type definition to model_types.h, where

 

 

 

model is the model name.

 

 

 

If a value is specified for Header file, import

 

 

 

the data type definition from the specified

 

 

 

header file.

 

 

Exported

Export the data type definition to a header

 

 

 

file, which can be specified in the Header

 

 

 

file field. If no value is specified for Header

 

 

 

file, the header file name defaults to type.h,

 

 

 

wheretype is the data type name.

 

 

Imported

Import the data type definition from a header

 

 

 

file, which can be specified in the Header

 

 

 

file field. If no value is specified for Header

 

 

 

file, the header file name defaults to type.h,

 

 

 

wheretype is the data type name.

 

Header file

Name of a C header file from which a data type definition is imported, or to which a data type definition is exported, based on the value of Data scope. If this field is specified, the specified name is used during code generation for importing or exporting. If this field is empty, the value defaults to type.h if Data scope

7-148

Simulink.NumericType

equals Imported or Exported, or defaults to model_types.h if

Data scope equals Auto.

Description

Description of this data type. This field is intended for use in documenting this data type. Simulink software ignores it.

Signedness

Specifies whether the data type is signed or unsigned, or inherits its signedness. Set the option to Signed, Unsigned, or Auto. This option is enabled only for fixed-point data type modes.

7-149

Simulink.NumericType

Word-Length

Word length in bits of the fixed-point data type. This option is enabled only for fixed-point data type modes.

Fraction length

Number of bits to the right of the binary point. This option is enabled only if the data type mode is Fixed-point: binary

point scaling.

7-150

Simulink.NumericType

Slope

Slope for slope and bias scaling. data type mode is Fixed-point:

This option is enabled only if the slope and bias scaling.

7-151

Simulink.NumericType

Bias

Bias for slope and bias scaling. This option is enabled only if the data type mode is Fixed-point: slope and bias scaling. See the preceding figure.

7-152

Simulink.NumericType

Properties

 

Name

Access

Description

 

 

Bias

RW

Bias used for slope and bias scaling of

 

 

 

 

a fixed-point data type. This field is

 

 

 

 

intended for use by the Simulink Fixed

 

 

 

 

Point product. (Bias)

 

 

DataScope

RW

A string specifying whether the data type

 

 

 

 

definition should be imported from, or

 

 

 

 

exported to, a header file during code

 

 

 

 

generation. (Data scope)

 

 

DataTypeMode

RW

String that specifies the data type

 

 

 

 

mode of this numeric type. Valid

 

 

 

 

values are 'Double', 'Boolean',

 

 

 

 

'Single', 'Fixed-point: unspecified

 

 

 

 

scaling', 'Fixed-point: binary

 

 

 

 

point scaling', and 'Fixed-point:

 

 

 

 

slope and bias scaling'. (Data type

 

 

 

 

mode)

 

 

DataTypeOverride

RW

String that specifies the data type override

 

 

 

 

mode. Valid values are Inherit and Off.

 

 

 

 

(Data type override)

 

 

Description

RW

Description of this data type. (Description)

 

 

 

 

 

 

7-153

Simulink.NumericType

 

Name

Access

Description

 

 

Fixedexponent

RW

Exponent used for binary point scaling.

 

 

 

 

This property equals -FractionLength.

 

 

 

 

Setting this property causes Simulink

 

 

 

 

software to set the FractionLength and

 

 

 

 

Slope properties accordingly, and vice

 

 

 

 

versa. This property applies only if the

 

 

 

 

DataTypeMode is Fixed-point: binary

 

 

 

 

point scaling or Fixed-point: slope

 

 

 

 

and bias scaling. It does not appear on

 

 

 

 

the object’s Property dialog box, but can

 

 

 

 

be accessed from the MATLAB command

 

 

 

 

prompt.

 

 

FractionLength

RW

Integer that specifies the size in

 

 

 

 

bits of the fractional portion of the

 

 

 

 

fixed-point number. This property equals

 

 

 

 

-Fixedexponent. Setting this property

 

 

 

 

causes Simulink software to set the

 

 

 

 

Fixedexponent property accordingly, and

 

 

 

 

vice versa. This field is intended for use

 

 

 

 

by the Simulink Fixed Point product.

 

 

 

 

(Fraction length)

 

 

HeaderFile

RW

A string that specifies the name of a

 

 

 

 

C header file from which a data type

 

 

 

 

definition is imported, or to which a data

 

 

 

 

type definition is exported, during code

 

 

 

 

generation. (Header file)

 

 

IsAlias

RW

Integer that specifies whether to use the

 

 

 

 

name of this object as the name of the data

 

 

 

 

type that it specifies. Valid values are 1

 

 

 

 

(yes) or 0 (no). (Is alias)

 

7-154

Simulink.NumericType

 

Name

Access

Description

 

 

Signedness

RW

Boolean that specifies whether this data

 

 

 

 

type is signed, unsigned, or inherits its

 

 

 

 

signedness. Valid values are 1 (signed), 0

 

 

 

 

(unsigned), or Auto (inherit signedness).

 

 

 

 

(Signedness)

 

 

Slope

RW

Slope for slope and bias scaling of

 

 

 

 

fixed-point numbers. This property

 

 

 

 

equals SlopeAdjustmentFactor

 

 

 

 

* 2^Fixedexponent. If

 

 

 

 

SlopeAdjustmentFactor is 1.0, Simulink

 

 

 

 

software displays the value of this field as

 

 

 

 

2^SlopeAdjustmentFactor. Otherwise,

 

 

 

 

it displays it as a numeric value.

 

 

 

 

Setting this property causes Simulink

 

 

 

 

software to set the Fixedexponent and

 

 

 

 

SlopeAdjustmentFactor properties

 

 

 

 

accordingly, and vice versa. This

 

 

 

 

property appears only if DataTypeMode

 

 

 

 

is Fixed-point: slope and bias

 

 

 

 

scaling. (Slope)

 

 

SlopeAdjustmentFactor

RW

Slope for slope and bias scaling of

 

 

 

 

fixed-point numbers. Setting this property

 

 

 

 

causes Simulink software to adjust the

 

 

 

 

Slope property accordingly, and vice

 

 

 

 

versa. This property applies only if

 

 

 

 

DataTypeMode is Fixed-point: slope

 

 

 

 

and bias scaling. It does not appear on

 

 

 

 

the object’s Property dialog box, but can

 

 

 

 

be accessed from the MATLAB command

 

 

 

 

prompt.

 

 

WordLength

RW

Integer that specifies the word size of this

 

 

 

 

data type. This field is intended for use by

 

 

 

 

the Simulink Fixed Point product. This

 

 

 

 

 

 

7-155

Simulink.NumericType

Name

Methods

Name

isboolean

isdouble

isfixed

isfloat

Access Description

property appears only if DataTypeMode is Fixed-point. (Word Length)

Description

Determine whether data type is Boolean

Returns 1 when the DataTypeMode is 'Boolean', 0 otherwise.

Determine whether data type is double precision

Returns 1 when the DataTypeMode is 'Double', 0 otherwise.

Determine whether data type is fixed point

Returns 1 when the DataTypeMode is any of the fixed-point options, 0 otherwise. The fixed-point options are:

'Fixed-point: unspecified scaling'

'Fixed-point: binary point scaling'

'Fixed-point: slope and bias scaling'

Determine whether data type is floating point

Returns 1 when the DataTypeMode is

'Double' or 'Single', 0 otherwise.

7-156

Simulink.NumericType

 

Name

Description

 

 

isscalingbinarypoint

Determine whether data type has binary

 

 

 

point scaling

 

 

 

Returns 1 when the data type has binary

 

 

 

point scaling or trivial slope and bias

 

 

 

scaling, 0 otherwise. Slope and bias scaling

 

 

 

is trivial when the slope is an integer power

 

 

 

of two and the bias is zero.

 

 

 

DataTypeMode is 'Fixed-point: binary

 

 

 

point scaling'

 

 

isscalingslopebias

Determine whether data type has nontrivial

 

 

 

slope and bias scaling

 

 

 

Returns 1 when the data type has nontrivial

 

 

 

slope and bias scaling, 0 otherwise. Slope

 

 

 

and bias scaling is trivial when the slope is

 

 

 

an integer power of two and the bias is zero.

 

 

 

DataTypeMode is 'Fixed-point: slope

 

 

 

and bias scaling'

 

 

isscalingunspecified

Determine whether data type has

 

 

 

unspecified scaling

 

 

 

Returns 1 when the data type is fixed point

 

 

 

and its scaling has not been specified, 0

 

 

 

otherwise.

 

 

 

DataTypeMode is 'Fixed-point:

 

 

 

unspecified scaling'

 

 

issingle

Determine whether data type is

 

 

 

single-precision

 

 

 

Returns 1 when the DataTypeMode is

 

 

 

'Single', 0 otherwise.

 

7-157

Simulink.NumericType

See Also

“Generate Code Including User-Defined Data Types” in the Embedded

 

Coder documentation

7-158

Simulink.Parameter

Purpose

Specify value, value range, data type, and other properties of block

 

parameter

Description

This class enables you to create workspace objects that you can then

 

use as the values of block parameters, (for example, the value of the

 

Gain parameter of a Gain block. You can create a Simulink.Parameter

 

object in the base MATLAB workspace or a model workspace. However,

 

to create the object in a model workspace, you must set the object

 

storage class to Auto.

 

Parameter objects let you specify not only the value of a parameter

 

but also other information about the parameter, such as the

 

parameter’s purpose, its dimensions, or its minimum and maximum

 

values. Some Simulink products use this information. For example,

 

Simulink and Simulink Coder products use information specified by

 

Simulink.Parameter objects to determine whether the parameter is

 

tunable (see “Tunable Parameters” in Simulink User’s Guide).

 

Simulink performs range checking of parameter values. The software

 

alerts you when the parameter object value lies outside a range that

 

corresponds to its specified minimum and maximum values and data

 

type.

 

You can use the Simulink.Parameter dialog box to define a

 

Simulink.Parameter object. To open the dialog box, in the Model

 

Explorer, select the base workspace or a model workspace and select

 

Add > Simulink Parameter.

7-159

Simulink.Parameter

Property

Dialog

Box

Value

Value of the parameter. You can use MATLAB expressions to specify the numeric type, dimensions, and data type of the parameter (see “Data Types Supported by Simulink”). You can also specify fixed-point values for block parameters (see

“Specifying Fixed-Point Values Directly” in the Simulink Fixed Point documentation). The following examples illustrate this syntax.

7-160

Simulink.Parameter

 

Expression

Description

 

 

single(1.0)

Specifies a single-precision value of

 

 

 

1.0

 

 

int8(2)

Specifies an 8-bit integer of value 2

 

 

int32(3+2i)

Specifies a complex value whose

 

 

 

real and imaginary parts are 32-bit

 

 

 

integers

 

 

fi(2.3,true,16,3)

Specifies a signed fixed-point numeric

 

 

 

object having a value of 2.3, a word

 

 

 

length of 16 bits, and a fraction length

 

 

 

of 3.

 

 

struct('A',20,'B',5)

Specifies a structure for a bus with two

 

 

 

signals, A and B, with double-precision

 

 

 

values of 20 and 5, respectively.

 

 

 

The shape and attributes of the

 

 

 

structure must match the shape and

 

 

 

attributes of the elements in the bus.

 

 

 

For information about specifying

 

 

 

an initial condition structure, see

 

 

 

“Specify Initial Conditions for Bus

 

 

 

Signals”.

 

Note Specifying a typed expression as the Value property of the parameter object overrides the current setting of the Data type property.

If Value evaluates to a MATLAB structure, then in the

Configuration Parameters > Diagnostics > Data Validity pane, set “Underspecified initialization detection” to simplified.

7-161

Simulink.Parameter

Data type

Data type of the parameter. You can either select a data type from the adjacent pulldown menu or enter a string. If you select auto (the default), the block that references the parameter object determines the data type of the variable used to represent this parameter in code generated from the model. If you enter a string, it must evaluate to one of the following:

A built-in data type that Simulink supports (see “Data Types Supported by Simulink” ).

A Simulink.NumericType object

A Simulink.AliasType object

A Simulink.Bus object (using the Bus: <object name> option)

You can use the Bus Editor to define or edit a Simulink.Parameter object with a bus object for its data type. Use one of these approaches:

Select the File > Create/Edit a Simulink.Parameter object menu item.

Click the Create/Edit a Simulink.Parameter object icon () from the toolbar.

You can then edit the Simulink.Parameter object in the MATLAB Editor and evaluate the code to create or update the values for this Simulink.Parameter object.

Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Data type parameter. (See “Specify Data Types Using Data Type Assistant” in Simulink User’s Guide.)

7-162

Simulink.Parameter

Note If you specify a parameter object data type using the Data type property, it overrides any typed expression in the Value property and changes the value to be untyped.

Units

Measurement units in which this value is expressed (for example, inches). This field is intended for use in documenting this parameter. Simulink ignores it.

Dimensions

Dimensions of the parameter. Simulink determines the dimensions from the entry in the Value field of this parameter. You cannot set this field yourself.

Complexity

Numeric type (i.e., real or complex) of the parameter. Simulink determines the numeric type of this parameter from the entry in the Value field of this parameter. You cannot set this field yourself.

Minimum

Minimum value that the parameter can have. The default value is [] (unspecified). Specify a finite, real, double, scalar value.

Note If you specify a bus object as the data type for a parameter, do not set the minimum value for bus data on the parameter property dialog box. Simulink ignores this setting. Instead, set the minimum values for bus elements of the bus object specified as the data type. For information on the Minimum property of a bus element, see Simulink.BusElement.

Simulink generates a warning if the parameter value is less than the minimum value or if the minimum value is outside the

7-163

Simulink.Parameter

range of the parameter data type. When updating the diagram or starting a simulation, Simulink generates an error in these cases.

Maximum

Maximum value that the parameter can have. The default value is [] (unspecified). Specify a finite, real, double, scalar value.

Note If you specify a bus object as the data type for a parameter, do not set the maximum value for bus data on the parameter property dialog box. Simulink ignores this setting. Instead, set the maximum values for bus elements of the bus object specified as the data type. For information on the Maximum property of a bus element, see Simulink.BusElement.

Simulink generates a warning if the parameter value is greater than the maximum value or if the maximum value is outside the range of the parameter data type. When updating the diagram or starting a simulation, Simulink generates an error in these cases.

Storage class

Storage class of this parameter. Simulink code generation products use this property to allocate memory for this parameter in generate code. For more information, see “Tunable Parameter Storage Classes”.

Alias

Alternate name for this parameter. Simulink ignores this setting.

Alignment

Data alignment boundary, specified in number of bytes. The starting memory address for the data allocated for the parameter will be a multiple of the Alignment setting. The default value is -1, which specifies that the code generator should determine an optimal alignment based on usage. Otherwise, specify a positive integer that is a power of 2, not exceeding 128. This field is intended for use by Simulink Coder software (see “Configure Data

7-164

Simulink.Parameter

Properties

Alignment for Function Implementations”). Simulink software ignores this setting.

Description

Description of this parameter. This field is intended for use in documenting this parameter. Simulink ignores it.

 

Name

Access

Description

 

 

Value

RW

Value of this parameter. (Value)

 

 

CoderInfo

RW

Information used by Simulink Coder

 

 

 

 

software for generating code for this

 

 

 

 

parameter. The value of this property is

 

 

 

 

an object of Simulink.ParamCoderInfo

 

 

 

 

class.

 

 

Description

RW

String that describes this parameter.

 

 

 

 

This property is intended for user

 

 

 

 

use. Simulink itself does not use it.

 

 

 

 

(Description)

 

 

DataType

RW

String specifying the data type of this

 

 

 

 

parameter. (Data type)

 

 

Min

RW

Minimum value that this parameter can

 

 

 

 

have. (Minimum)

 

 

Max

RW

Maximum value that this parameter can

 

 

 

 

have. (Maximum)

 

 

DocUnits

RW

Measurement units in which this

 

 

 

 

parameter’s value is expressed. (Units)

 

 

Complexity

RO

String specifying the numeric type of this

 

 

 

 

parameter. Valid values are 'real’ or

 

 

 

 

'complex'. (Complexity)

 

 

Dimensions

RO

Vector specifying the dimensions of this

 

 

 

 

parameter. (Dimensions)

 

7-165

Simulink.ParamCoderInfo

Purpose

Description

Property

Dialog

Box

Properties

Specify information needed to generate code for parameter

Simulink software creates an instance of this class for each instance of a Simulink.Parameter object that it creates. Simulink software uses the Simulink.ParamCoderInfo object to store information needed to generate code for the parameter specified by the Simulink.Parameter object.

You can set the properties of an instance of this class via the CoderInfo property or the property dialog box of the Simulink.Parameter object that uses it. For example, the following MATLAB expression sets the

StorageClass property of a Simulink.ParamCoderInfo object used by a parameter object name myparam.

myparam.CoderInfo.StorageClass = 'exportedGlobal';

Use the Code Generation Options section of the Simulink.Parameter property dialog box to set the StorageClass, Alias, and Alignment properties of objects of this class.

 

Name

Description

 

 

Alias

Alternate name for this parameter.

 

 

Alignment

Data alignment boundary for this parameter.

 

 

 

See “Configure Data Alignment for Function

 

 

 

Implementations” in the Embedded Coder

 

 

 

documentation for more information.

 

 

CustomAttributes

Custom storage class attributes of this

 

 

 

parameter. See “Introduction to Custom

 

 

 

Storage Classes” in the Embedded Coder

 

 

 

documentation for more information.

 

7-166

Simulink.ParamCoderInfo

 

Name

Description

 

 

CustomStorageClass

Custom storage class of this parameter.

 

 

StorageClass

Storage class of this parameter. For more

 

 

 

information, see “Parameters” in the Simulink

 

 

 

Coder documentation.

 

7-167

Simulink.RunTimeBlock

Purpose

Description

Parent

Class

Derived

Classes

Property

Summary

Allow Level-2 MATLAB S-function and other MATLAB programs to get information about block while simulation is running

This class allows a Level-2 MATLAB S-function or other MATLAB program to obtain information about a block. Simulink software creates an instance of this class or a derived class for each block in a model. Simulink software passes the object to the callback methods of Level-2 MATLAB S-functions when it updates or simulates a model, allowing the callback methods to get block-related information from and provide such information to Simulink software. See “Write Level-2 MATLAB S-Functions” in Writing S-Functions for more information. You can also use instances of this class in MATLAB programs to obtain information about blocks during a simulation. See “Access Block Data During Simulation” for more information.

Note Simulink.RunTimeBlock objects do not support MATLAB sparse matrices. For example, the following line of code attempts to assign a sparse identity matrix to the run-time object’s output port data. This line of code in a Level-2 MATLAB S-function produces an error:

block.Outport(1).Data = speye(10);

None

Simulink.MSFcnRunTimeBlock

 

Name

Description

 

 

“BlockHandle”

Block’s handle.

 

 

“CurrentTime”

Current simulation time.

 

 

 

 

 

7-168

Simulink.RunTimeBlock

Method

Summary

 

Name

Description

 

 

“NumDworks”

Number of discrete work vectors used by the

 

 

 

block.

 

 

“NumOutputPorts”

Number of block output ports.

 

 

“NumContStates”

Number of block’s continuous states.

 

 

“NumDworkDiscStates”

Number of block’s discrete states

 

 

“NumDialogPrms”

Number of parameters that can be entered

 

 

 

on S-function block’s dialog box.

 

 

“NumInputPorts”

Number of block’s input ports.

 

 

“NumRuntimePrms”

Number of run-time parameters used by

 

 

 

block.

 

 

“SampleTimes”

Sample times at which block produces

 

 

 

outputs.

 

 

Name

Description

 

 

“ContStates”

Get a block’s continuous states.

 

 

“DataTypeIsFixedPoint”

Determine whether a data type is

 

 

 

fixed point.

 

 

“DatatypeName”

Get name of a data type supported

 

 

 

by this block.

 

 

“DatatypeSize”

Get size of a data type supported by

 

 

 

this block.

 

 

“Derivatives”

Get a block’s continuous state

 

 

 

derivatives.

 

 

“DialogPrm”

Get a parameter entered on an

 

 

 

S-function block’s dialog box.

 

 

“Dwork”

Get one of a block’s DWork vectors.

 

 

 

 

 

7-169

Simulink.RunTimeBlock

 

Name

Description

 

 

“FixedPointNumericType”

Determine the properties of a

 

 

 

fixed-point data type.

 

 

“InputPort”

Get one of a block’s input ports.

 

 

“OutputPort”

Get one of a block’s output ports.

 

 

“RuntimePrm”

Get one of the run-time parameters

 

 

 

used by a block.

 

Properties

BlockHandle

Description

Block’s handle.

Access

RO

CurrentTime

Description

Current simulation time.

Access

RO

NumDworks

Description

Number of data work vectors.

Access

RW

See Also ssGetNumDWork

7-170

Simulink.RunTimeBlock

NumOutputPorts

Description

Number of output ports.

Access

RW

See Also

ssGetNumOutputPorts

NumContStates

Description

Number of continuous states.

Access

RW

See Also

ssGetNumContStates

NumDworkDiscStates

Description

Number of discrete states. In a MATLAB S-function, you need to use DWorks to set up discrete states.

Access

RW

See Also

ssGetNumDiscStates

NumDialogPrms

Description

Number of parameters declared on the block’s dialog. In the case of the S-function, it returns the number of parameters listed as a comma-separated list in the S-function parameters dialog field.

7-171

Simulink.RunTimeBlock

Access

RW

See Also

ssGetNumSFcnParams

NumInputPorts

Description

Number of input ports.

Access

RW

See Also

ssGetNumInputPorts

NumRuntimePrms

Description

Number of run-time parameters used by this block. See “Run-Time Parameters” for more information.

Access

RW

See Also

ssGetNumSFcnParams

SampleTimes

Description

Block’s sample times.

Access

RW for MATLAB S-functions, RO for all other blocks.

7-172

Simulink.RunTimeBlock

Methods

ContStates

Purpose

Get a block’s continuous states.

Syntax

states = ContStates();

Description

Get vector of continuous states.

See Also

ssGetContStates

DataTypeIsFixedPoint

Purpose

Determine whether a data type is fixed point.

Syntax

bVal = DataTypeIsFixedPoint(dtID);

Arguments

dtID

Integer value specifying the ID of a data type.

Description

Returns true if the specified data type is a fixed-point data type.

DatatypeName

Purpose

Get the name of a data type.

Syntax

name = DatatypeName(dtID);

Arguments

dtID

7-173

Simulink.RunTimeBlock

Integer value specifying ID of a data type.

Description

Returns the name of the data type specified by dtID.

See Also

“DatatypeSize”

DatatypeSize

Purpose

Get the size of a data type.

Syntax

size = DatatypeSize(dtID);

Arguments

dtID

Integer value specifying the ID of a data type.

Description

Returns the size of the data type specified by dtID.

See Also

“DatatypeName”

Derivatives

Purpose

Get derivatives of a block’s continuous states.

Syntax

derivs = Derivatives();

Description

Get vector of state derivatives.

See Also

ssGetdX

7-174

Simulink.RunTimeBlock

DialogPrm

Purpose

Get an S-function’s dialog parameters.

Syntax

param = DialogPrm(pIdx);

Arguments

pIdx

Integer value specifying the index of the parameter to be returned.

Description

Get the specified dialog parameter. In the case of the S-function, each DialogPrm corresponds to one of the elements in the comma-separated list of parameters in the S-function parameters dialog field.

See Also

ssGetSFcnParam, “RuntimePrm”

Dwork

Purpose

Get one of a block’s DWork vectors.

Syntax

dworkObj = Dwork(dwIdx);

Arguments

dwIdx

Integer value specifying the index of a work vector.

Description

Get information about the DWork vector specified by dwIdx where dwIdx is the index number of the work vector. This method returns an

object of type Simulink.BlockCompDworkData.

7-175

Simulink.RunTimeBlock

See Also

ssGetDWork

FixedPointNumericType

Purpose

Get the properties of a fixed-point data type.

Syntax

eno = FixedPointNumericType(dtID);

Arguments

dtID

Integer value specifying the ID of a fixed-point data type.

Description

Returns an object of embedded.Numeric class that contains the attributes of the specified fixed-point data type.

Note embedded.Numeric is also the class of the numerictype objects created by Fixed-Point Toolbox software. For information on the properties defined by embedded.Numeric class, see numerictype Object Properties.

InputPort

Purpose

Get an input port of a block.

Syntax

port = InputPort(pIdx);

Arguments

pIdx

Integer value specifying the index of an input port.

7-176

Simulink.RunTimeBlock

Description

Get the input port specified by pIdx, where pIdx is the index number of the input port. For example,

port = rto.InputPort(1)

returns the first input port of the block represented by the run-time object rto.

This method returns an object of type

Simulink.BlockPreCompInputPortData or Simulink.BlockCompInputPortData, depending on whether the model that contains the port is uncompiled or compiled. You can use this object to get and set the input port’s uncompiled or compiled properties, respectively.

See Also

ssGetInputPortSignalPtrs, Simulink.BlockPreCompInputPortData, Simulink.BlockCompInputPortData, “OutputPort”

OutputPort

Purpose

Get an output port of a block.

Syntax

port = OutputPort(pIdx);

Arguments

pIdx

Integer value specifying the index of an output port.

Description

Get the output port specified by pIdx, where pIdx is the index number of the output port. For example,

port = rto.InputPort(1)

7-177

Simulink.RunTimeBlock

returns the first output port of the block represented by the run-time object rto.

This method returns an object of type

Simulink.BlockPreCompOutputPortData or Simulink.BlockCompOutputPortData, depending on whether the model that contains the port is uncompiled or compiled, respectively. You can use this object to get and set the output port’s uncompiled or compiled properties, respectively.

See Also ssGetInputPortSignalPtrs,

Simulink.BlockPreCompOutputPortData, Simulink.BlockCompOutputPortData

RuntimePrm

Purpose

Get an S-function’s run-time parameters.

Syntax

param = RuntimePrm(pIdx);

Arguments

pIdx

Integer value specifying the index of a run-time parameter.

Description

Get the run-time parameter whose index is pIdx.

See Also

ssGetRunTimeParamInfo

7-178

Simulink.SampleTime

Purpose

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 character string 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 character string that represents the annotation of a specific sample time (for example, ’D1’)

OwnerBlock

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

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.

7-179

Simulink.SampleTime

Copy

Value. To learn how value classes affect copy operations, see Copying

Semantics

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'

7-180

Simulink.SampleTime

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

See Also Simulink.Block.getSampleTimes |

Simulink.BlockDiagram.getSampleTimes

7-181

Simulink.ScopeDataLogs

Purpose

Store data logged by Scope signal viewer

Description

Note The Simulink.ScopeDataLogs class is used in conjunction with the ModelDataLogs logging data format. The ModelDataLogs format is supported for backwards compatibility. The ModelDataLogs format will be removed in a future release.

For new models, use the Dataset logging format. If you use the Dataset format for signal logging, then Simulink does not log the signals configured to be logged in the Signal Viewer. Explicitly mark the signal for signal logging by using the Signal Properties dialog box. To access the Signal Properties dialog box, right-click a signal and from the context menu, select Properties.

Simulink software creates instances of this class to log data displayed on Scope viewers (see “Visualize Results”). In particular, if you have enabled data logging for a model, Simulink software creates an instance of this class for each scope viewer enabled for logging in the model and assigns it to a property of the model’s Simulink.ModelDataLogs object. The instance created for each viewer has a Name property whose value is the name specified on the History pane of the viewer’s parameter dialog box (see Scope for more information). The instance also has an axes property for each of the scope’s axes labeled Axes1, Axes2, etc. The value of each axes property is itself a Simulink.ScopeDataLogs object that contains Simulink.Timeseries objects, one for each signal displayed on the axes. The time series objects contain the signal data displayed on the axes.

7-182

Simulink.ScopeDataLogs

Consider, for example, the following model:

This model displays signals out1 and out2 on a scope viewer that has only one set of axes.

7-183

Simulink.ScopeDataLogs

The model enables data logging for the scope viewer under the variable name ScopeData and for the model as a whole under the default variable name logsout.

7-184

Simulink.ScopeDataLogs

After simulation of the model, the MATLAB workspace contains a Simulink.ModelDataLogs object named logsout containing a Simulink.ScopeDataLogs object that in turn contains a

Simulink.ScopeDataLogs object that contains Simulink.Timeseries objects that contain the times series data for signals out1 and out 2.

You can use Simulink data object dot notation to access the data, e.g.,

>> logsout.ScopeData.axes1

ans =

 

 

Simulink.ScopeDataLogs (axes1):

 

Name

elements

Simulink Class

out1

1

Timeseries

out2

1

Timeseries

See Also “Signal Logging”, Simulink.ModelDataLogs, Simulink.SubsysDataLogs, Simulink.Timeseries, Simulink.TsArray, Simulink.SimulationData.Dataset, who, whos, unpack

7-185

Simulink.sdi.DiffRunResult

Purpose

Results from comparing two simulation runs

Description The Simulink.sdi.DiffRunResult class manages the results from comparing two simulation runs. A Simulink.sdi.DiffRunResult object contains a Simulink.sdi.DiffSignalResult object for each signal compared.

Construction The function Simulink.sdi.compareRuns returns a handle to a

Simulink.sdi.DiffRunResult object.

Properties runID1

Run ID, a unique number identifying the first run compared.

runID2

Run ID, a unique number identifying the second run compared.

count

Number of compared signal results.

matlabVersion

Version of MATLAB used to create an instance of

Simulink.sdi.DiffRunResult.

dateCreated

Date of object creation, stored in serial date number format.

Methods

Copy

Semantics

Examples

getResultByIndex

Return signal comparison result,

 

object

Handle. To learn how handle classes affect copy operations, see Copying Objects in the MATLAB Programming Fundamentals documentation.

The function Simulink.sdi.compareRuns returns a Simulink.sdi.DiffRunResult object containing the results

7-186

Simulink.sdi.DiffRunResult

of the comparison. The Simulink.sdi.DiffRunResult object contains a Simulink.sdi.DiffSignalResult object for each signal comparison between the two simulation runs.

% Configure model "sldemo_f14" for logging and simulate

set_param('sldemo_f14/Pilot','WaveForm','square');

simOut = sim('sldemo_f14', 'SaveOutput','on', ...

'SaveFormat', 'StructureWithTime', ...

'ReturnWorkspaceOutputs', 'on');

%Create a Simulation Data Inspector run, Simulink.sdi.Run, from simO runID1 = Simulink.sdi.createRun('First Run','namevalue',{'simOut'},{s

%Simulate again

set_param('sldemo_f14/Pilot','WaveForm','sawtooth');

simOut = sim('sldemo_f14', 'SaveOutput','on', ...

'SaveFormat', 'StructureWithTime', ...

'ReturnWorkspaceOutputs', 'on');

% Create another Simulation Data Inspector run

runID2 = Simulink.sdi.createRun('Second Run','namevalue',{'simOut'},{

%Compare two runs and get an instance of Simulink.sdi.DiffRunResult diff = Simulink.sdi.compareRuns(runID1, runID2);

%Get the number of signal comparison results

count = diff.count;

% Iterate over

results and find out if signals match

for i=1:count

 

 

% Get the

Simulink.sdi.DiffSignalResult, diffSignal

diffSignal

=

diff.getResultByIndex(i);

signalID1

=

diffSignal.signalID1;

signalID2

 

= diffSignal.signalID2;

match

 

= diffSignal.match;

if match

7-187

Simulink.sdi.DiffRunResult

disp([num2str(signalID1) ' and ' num2str(signalID2)...

' match']);

else

disp([num2str(signalID1) ' and ' num2str(signalID2)...

' don''t match']);

end

end

See Also Simulink.sdi.createRun | Simulink.sdi.compareRuns |

Simulink.sdi.DiffSignalResult

How To

• “Record and Inspect Signal Data Programmatically”

7-188

Simulink.sdi.DiffRunResult.getResultByIndex

Purpose

Return signal comparison result, Simulink.sdi.DiffSignalResult

 

object

Syntax

diffSignalObj = diffRunObj.getResultByIndex(index)

Description

diffSignalObj = diffRunObj.getResultByIndex(index) returns

 

the Simulink.sdi.DiffSignalResult object, diffSignalObj, which

 

contains the comparison results for a signal. diffRunObj is an instance

 

of a Simulink.sdi.DiffRunResult class, which contains an array

 

of signal comparison results, where each element is an instance of a

 

Simulink.sdi.DiffSignalResult class.

Input

index

Arguments

An index to the array of Simulink.sdi.DiffSignalResult

 

objects contained in a Simulink.sdi.DiffRunResult object.

Output

diffSignalObj

Arguments

Handle to a Simulink.sdi.DiffSignalResult object

 

representing the results of comparing two signals between

 

simulation runs.

Examples

The function Simulink.sdi.compareRuns returns a

 

Simulink.sdi.DiffRunResult object containing the results

 

of the comparison. The Simulink.sdi.DiffRunResult object contains

 

a Simulink.sdi.DiffSignalResult object for each signal comparison

 

between the two simulation runs. diff.getResultByIndex returns the

 

Simulink.sdi.DiffSignalResult object for each signal comparison.

 

% Configure model "sldemo_f14" for logging and simulate

 

set_param('sldemo_f14/Pilot','WaveForm','square');

 

simOut = sim('sldemo_f14', 'SaveOutput','on', ...

 

'SaveFormat', 'StructureWithTime', ...

 

'ReturnWorkspaceOutputs', 'on');

 

% Create a Simulation Data Inspector run, Simulink.sdi.Run, from simO

7-189

Simulink.sdi.DiffRunResult.getResultByIndex

 

runID1 = Simulink.sdi.createRun('First Run','namevalue',{'simOut'},{simOu

 

% Simulate again

 

set_param('sldemo_f14/Pilot','WaveForm','sawtooth');

 

simOut = sim('sldemo_f14', 'SaveOutput','on', ...

 

 

'SaveFormat', 'StructureWithTime', ...

 

 

'ReturnWorkspaceOutputs', 'on');

 

% Create another Data Inspector run and get signal IDs

 

runID2 = Simulink.sdi.createRun('Second Run','namevalue',{'simOut'},{simO

 

% Compare two runs and get an instance of Simulink.sdi.DiffRunResult

 

diff = Simulink.sdi.compareRuns(runID1, runID2);

 

% Get the number of signal comparison results

 

count = diff.count;

 

% Iterate over results and display the comparison results

 

for i=1:count

 

 

diffSignal

= diff.getResultByIndex(i);

 

signalID1

= diffSignal.signalID1;

 

signalID2

= diffSignal.signalID2;

 

match

= diffSignal.match;

 

if match

 

 

disp([num2str(signalID1) ' and ' num2str(signalID2)...

 

' match']);

 

else

 

 

disp([num2str(signalID1) ' and ' num2str(signalID2)...

 

' don''t match']);

 

end

 

 

end

 

See Also

Simulink.sdi.Run | Simulink.sdi.Signal |

 

Simulink.sdi.DiffRunResult | Simulink.sdi.DiffSignalResult

 

| Simulink.sdi.compareRuns

7-190

Simulink.sdi.DiffRunResult.getResultByIndex

How To

• “Record and Inspect Signal Data Programmatically”

7-191

Simulink.sdi.DiffSignalResult

Purpose

Results from comparing two signals

Description

The Simulink.sdi.DiffSignalResult object manages the results from

 

comparing two signals. A Simulink.sdi.DiffSignalResult object

 

contains the value differences of the signals, the tolerance data, and the

 

data after any specified synchronization methods are performed.

Construction

The function Simulink.sdi.compareSignals returns a handle to

 

a Simulink.sdi.DiffSignalResult object, which contains the

 

comparison results.

 

A Simulink.sdi.DiffSignalResult object is also created

 

when the function Simulink.sdi.compareRuns creates a

 

Simulink.sdi.DiffRunResult object, which in turn creates

 

Simulink.sdi.DiffSignalResult objects.

Properties

signalID1

 

Signal ID, a unique number identifying the first signal compared.

 

signalID2

 

Signal ID, a unique number identifying the second signal

 

compared.

 

match

 

A boolean indicating if the two timeseries objects match

 

according to the specified tolerance and time synchronization

 

options.

 

diff

 

A MATLAB timeseries object specifying the value differences

 

after synchronizing the two time series data.

 

tol

 

A MATLAB timeseries object specifying the actual absolute

 

tolerance value at each synchronized time point.

 

sync1

7-192

Simulink.sdi.DiffSignalResult

A MATLAB timeseries object specifying time series 1 after synchronization has been applied.

sync2

Copy

Semantics

Examples

See Also

A MATLAB timeseries object specifying time series 2 after synchronization has been applied.

Handle. To learn how handle classes affect copy operations, see Copying Objects in the MATLAB Programming Fundamentals documentation.

In this example, a Simulink.sdi.DiffSignalResult object is created after comparing two signals in the Simulation Data Inspector.

% Configure model "sldemo_f14" for logging and simulate

simOut = sim('sldemo_f14', 'SaveOutput','on', ...

'SaveFormat', 'StructureWithTime', ...

'ReturnWorkspaceOutputs','on');

% Create a Simulation Data Inspector run and get signal IDs

[~, ~, signalIDs] = Simulink.sdi.createRun('My Run','namevalue',{'MyD

sig1 = signalIDs(1); sig2 = signalIDs(2);

%Compare two signals, which returns the results in an instance of Si diff = Simulink.sdi.compareSignals(sig1, sig2);

%Find if the signals match

match = diff.match;

% Get the tolerance used in Simulink.sdi.compareSignals tolerance = diff.tol;

Simulink.sdi.DiffRunResult | Simulink.sdi.createRun |

Simulink.sdi.compareRuns

7-193

Simulink.sdi.DiffSignalResult

How To

• “Record and Inspect Signal Data Programmatically”

7-194

Simulink.sdi.Run

Purpose

Description

Construction

Properties

Methods

Manages signal data and metadata of simulation run

The Simulink.sdi.Run object contains the signal logging information for one simulation run, which includes the logged signal data, a run ID, and the total number of signals in the run.

The function Simulink.sdi.createRun creates a Simulink.sdi.Run object.

dateCreated

Date and time of the run, stored as a double.

description

User-specified description of the run. The default value is an empty string.

id

Read-only unique number to identify a run.

name

User-specified name of the run. The default value is an empty string.

signalCount

Number of signals in the run.

tag

User-specified string for categorization, identification, or attaching other information to this run. The default value is an empty string.

getSignal

Return object by signal ID

getSignalByIndex

Return object by index

7-195

Simulink.sdi.Run

Copy

Semantics

Examples

getSignalIDByIndex

Return signal ID at array index

isValidSignalID

Determine if signal ID is valid

 

within run

Handle. To learn how handle classes affect copy operations, see Copying Objects in the MATLAB Programming Fundamentals documentation.

The Simulink.sdi.Run object contains a Simulink.sdi.Signal object for each logged signal. This example creates a run from simulation data in the base workspace. It demonstrates how to access the Simulink.sdi.Run object from the Simulation Data Inspector . You can select which signals to view and then open the Simulation Data Inspector tool to inspect those signals.

% Configure model "sldemo_f14" for logging and simulate

simOut = sim('sldemo_f14', 'SaveOutput','on', ...

'SaveFormat', 'StructureWithTime', ...

'ReturnWorkspaceOutputs', 'on');

%Create a Simulation Data Inspector run, Simulink.sdi.Run, from simOut i runID = Simulink.sdi.createRun('My Run', 'base', {'simOut'});

%Get the handle to the run object, Simulink.sdi.Run, corresponding to th runObj = Simulink.sdi.getRun(runID);

%Get the name of the run

runName = runObj.name;

%Get number of signals numSignals = runObj.signalCount;

%To view the all of the signals in the run, select each signal in the ru for i=1:numSignals

signalObj = runObj.getSignalByIndex(i); signalObj.checked = true;

end

7-196

Simulink.sdi.Run

% Open the Simulation Data Inspector to inspect the selected signals. Simulink.sdi.view;

See Also Simulink.sdi.createRun | Simulink.sdi.getRun |

Simulink.sdi.view

How To

• “Record and Inspect Signal Data Programmatically”

7-197

Simulink.sdi.Run.getSignal

Purpose

Return Simulink.sdi.Signal object by signal ID

Syntax

signalObj = runObj.getSignal(signalID)

Description

signalObj = runObj.getSignal(signalID) returns the

 

Simulink.sdi.Signal object, signalObj, corresponding to the signal

 

ID, signalID, stored in the Simulink.sdi.Run object, runObj.

Input

signalID

Arguments

Signal ID, a unique number identifying a signal in a run in the

 

Simulation Data Inspector.

Output

signalObj

Arguments

Handle to a Simulink.sdi.Signal object representing a signal in

 

a run object, Simulink.sdi.Run.

Examples

The Simulink.sdi.Run method, getSignal, returns a signal object

 

representing the signal data and metadata in a run. You can modify the

 

signal object properties to configure the signal for plotting or comparing

 

to other signals in the Simulation Data Inspector.

 

% Configure model "sldemo_f14" for logging and simulate

 

simOut = sim('sldemo_f14', 'SaveOutput','on', ...

 

'SaveFormat', 'StructureWithTime', ...

 

'ReturnWorkspaceOutputs', 'on');

 

% Create a Simulation Data Inspector run

 

[runID,runIndex,signalIDs] = Simulink.sdi.createRun('My Run','base',{'sim

 

% Get the Simulink.sdi.Run object corresponding to the new run ID

 

runObj = Simulink.sdi.getRun(runID);

 

% Get the number of signals in the run

 

numSignals = runObj.signalCount;

7-198

Simulink.sdi.Run.getSignal

 

% Get the Simulink.sdi.Signal objects for each signal in the run and

 

for i = 1:numSignals

 

signalObjs(i) = runObj.getSignal(signalIDs(i));

 

signalObjs(i).checked = true;

 

end

See Also

Simulink.sdi.Run | Simulink.sdi.Signal |

 

Simulink.sdi.createRun

How To

• “Record and Inspect Signal Data Programmatically”

7-199

Simulink.sdi.Run.getSignalByIndex

Purpose

Return Simulink.sdi.Signal object by index

Syntax

signalObj = runObj(index)

Description

signalObj = runObj(index) returns the Simulink.sdi.Signal

 

object, signalObj, at the index into the array of signals contained in

 

the Simulink.sdi.Run object, runObj.

Input

index

Arguments

Number specifying an index to the array of signals contained in a

 

Simulink.sdi.Run object. The first index in the array is 1.

Output

signalObj

Arguments

Handle to a Simulink.sdi.Signal object representing a signal in

 

a run object, Simulink.sdi.Run.

Examples

The Simulink.sdi.Run method, getSignalByIndex, returns a signal

 

object representing the signal data and information in a run. You can

 

modify the signal object properties to configure the signal for plotting or

 

comparing to other signals in the Simulation Data Inspector.

 

% Configure model "sldemo_f14" for logging and simulate

 

simOut = sim('sldemo_f14','SaveOutput','on','SaveFormat', 'StructureWithT

 

'ReturnWorkspaceOutputs','on');

 

% Create a Simulation Data Inspector run

 

runID = Simulink.sdi.createRun('My Run','base',{'simOut'});

 

% Get the Simulink.sdi.Run object corresponding to the new run ID

 

runObj = Simulink.sdi.getRun(runID);

 

% Get the number of signals in the run

 

numSignals = runObj.signalCount;

 

% Get the Simulink.sdi.Signal object for the first signal in the run

7-200

Simulink.sdi.Run.getSignalByIndex

 

if numSignals > 0

 

signalObj = runObj.getSignalByIndex(1);

 

end

See Also

Simulink.sdi.Signal | Simulink.sdi.Run |

 

Simulink.sdi.createRun | Simulink.sdi.getRun

How To

• “Record and Inspect Signal Data Programmatically”

7-201

Simulink.sdi.Run.getSignalIDByIndex

Purpose

Return signal ID at array index

Syntax

signalID = runObj.getSignalIDByIndex(index)

Description

signalID = runObj.getSignalIDByIndex(index) returns the signal

 

ID for the signal at the specified index to the array of signals contained

 

in the Simulink.sdi.Run object, runObj.

Input

index

Arguments

Number specifying the index to the array of signals contained in a

 

Simulink.sdi.Run object. The first index in the array is 1.

Output

signalID

Arguments

Signal ID, a unique number identifying a signal in a run.

 

Examples

The Simulink.sdi.Run method, getSignalIDByIndex, returns

 

the signal ID corresponding to a signal in a run. With the signal

 

ID you can get the signal object representing the signal data and

 

metadata. You can compare two signals by passing their signal IDs to

 

Simulink.sdi.compareSignals.

 

% Configure model "sldemo_f14" for logging and simulate

 

simOut = sim('sldemo_f14','SaveOutput','on', ...

 

'SaveFormat','StructureWithTime', ...

 

'ReturnWorkspaceOutputs','on');

 

% Create a Simulation Data Inspector run

 

runID = Simulink.sdi.createRun('My Run','base',{'simOut'});

 

% Get the Simulink.sdi.Run object corresponding to the new run ID

 

runObj = Simulink.sdi.getRun(runID);

 

% Get the number of signals in the run

 

numSignals = runObj.signalCount;

7-202

Simulink.sdi.Run.getSignalIDByIndex

% Get the signal ID for the first signal in the run if numSignals > 0

signalID = runObj.getSignalIDByIndex(1);

end

See Also Simulink.sdi.Signal | Simulink.sdi.Run |

Simulink.sdi.createRun | Simulink.sdi.getRun |

Simulink.sdi.compareSignals

How To

• “Record and Inspect Signal Data Programmatically”

7-203

Simulink.sdi.Run.isValidSignalID

Purpose

Determine if signal ID is valid within run

Syntax

isValid = runObj.isValidSignalID(signalID)

Description

isValid = runObj.isValidSignalID(signalID) returns true if the

 

signal ID, signalID, corresponds to a signal in the run object, runObj.

 

Otherwise, it returns false.

Input

signalID

Arguments

Signal ID, a unique number identifying a signal stored in the

 

run object.

Output

isValid

Arguments

A Boolean value: true, if the signal exists; false, otherwise.

 

Examples

Before calling a function that takes a signal ID as input, verify that

 

the signal ID is valid.

 

% Configure model "sldemo_f14" for logging and simulate

 

simOut = sim('sldemo_f14','SaveOutput','on', ...

 

'SaveFormat','StructureWithTime', ...

 

'ReturnWorkspaceOutputs','on');

 

% Create a Simulation Data Inspector run

 

runID = Simulink.sdi.createRun('My Run','base',{'simOut'});

 

% Get the Simulink.sdi.Run object corresponding to the new run ID

 

runObj = Simulink.sdi.getRun(runID);

 

% Get the number of signals in the run

 

numSignals = runObj.signalCount;

 

% Get the signal ID for the first signal in the run

 

if numSignals > 0

 

signalID = runObj.getSignalIDByIndex(1);

7-204

Simulink.sdi.Run.isValidSignalID

end

% Before calling getSignal, check that the signalID is valid if runObj.isValidSignalID(signalID)

signalObj = runObj.getSignal(signalID)

end

See Also Simulink.sdi.Signal | Simulink.sdi.Run |

Simulink.sdi.createRun | Simulink.sdi.getRun

| Simulink.sdi.Run.getSignalByIndex |

Simulink.sdi.Run.isValidSignalID | Simulink.sdi.Run.getSignal

How To

• “Record and Inspect Signal Data Programmatically”

7-205

Simulink.sdi.Signal

Purpose

Manages signal time series data and metadata

Description

The Simulink.sdi.Signal object contains the signal logging

 

information for one simulation run. It also contains properties for

 

visualizing and comparing signals.

Construction

The function Simulink.sdi.createRun creates a Simulink.sdi.Run

 

object, which creates a Simulink.sdi.Signal object for each signal

 

in the simulation output.

Properties

Signal Properties (read only)

 

id

 

Signal ID, a unique number identifying the signal.

 

runID

 

Run ID, a unique number identifying the signal’s parent run.

 

rootSource

 

String to access the high-level logging structure this signal was

 

derived from.

 

timeSource

 

String to access the logged signal’s time vector.

 

dataSource

 

String to access the logged signal’s data values.

 

dataValues

 

Time series data for this signal.

 

blockSource

 

String specifying the path to the block that defines the signal.

 

modelSource

 

String specifying the name of the model that defines the signal.

7-206

Simulink.sdi.Signal

signalLabel

String specifying the name of the signal.

timeDim

For any given data sample, the time dimension.

sampleDims

Dimensions of a data sample.

portIndex

Index of the port that defines the signal.

channel

Channel index. This property applies to matrix data only. Matrix data is flattened into a scalar time series by using channels.

SID

“Simulink Identifier” on page 9-2 of the block that defines the signal.

Comparison Properties (read and write)

Each signal has properties that the Simulation Data Inspector uses for comparing two signals. The Simulation Data Inspector uses the comparison properties from the first signal passed in, also called the reference signal.

absTol

Absolute tolerance of the signal. Must be a positive number.

relTol

Relative tolerance of the signal. Must be a positive number.

syncMethod

7-207

Simulink.sdi.Signal

Copy

Semantics

Examples

Time synchronization method to align time vector when comparing signals. Possible values are: 'intersection',

'uniform', and 'union'.

interpMethod

Interpolation method to align data. Possible values are: 'zoh' and 'linear'.

Visualization Properties (read and write)

lineColor

Signal line color in the plot in the form of a vector [r g b]. r is the red component, g the green component, and b the blue component.

lineDashed

Signal line format in the plot

checked

Boolean specifying if the signal is selected for plotting: true for selected and false for cleared.

Handle. To learn how handle classes affect copy operations, see Copying Objects in the MATLAB Programming Fundamentals documentation.

Create a run and call the Simulink.sdi.getSignal function to get a Simulink.sdi.Signal object.

% Configure model "sldemo_f14" for logging and simulate

simOut = sim('sldemo_f14', 'SaveOutput','on', ...

'SaveFormat', 'StructureWithTime', ...

'ReturnWorkspaceOutputs', 'on');

%Create a Simulation Data Inspector run which returns a list of signal I [~,~,signalIDs] = Simulink.sdi.createRun('My Run', 'base', {'simOut'});

%Get the signal object corresponding to the first signal ID

7-208

Simulink.sdi.Signal

signalObj = Simulink.sdi.getSignal(signalIDs(1));

%signalObj is an instance of Simulink.sdi.Signal. Get the run ID for runID = signalObj.runID;

%Modify or define comparison and visualization properties for this s signalObj.syncMethod = 'intersection';

signalObj.lineColor = [1,0.4,0.6]; signalObj.lineDashed = '-'; signalObj.checked = true;

%View signals in the Simulation Data Inspector tool Simulink.sdi.view;

See Also Simulink.sdi.Run | Simulink.sdi.createRun |

Simulink.sdi.getSignal

How To

• “Record and Inspect Signal Data Programmatically”

7-209

Simulink.Signal

Purpose

Specify attributes of signal

Description This class enables you to create workspace objects that you can use to assign or validate the attributes of a signal or discrete state, such as its data type, numeric type, dimensions, and so on. You can use a signal object to:

Assign values to signal attributes that are left unassigned (have a value of -1 or auto) by the signal source.

Validate signal attributes whose values are explicitly assigned by the signal source. Such attributes have values other than -1 or auto. Successful validation guarantees that the signal has the attributes that you intended it to have.

You can create a Simulink.Signal object in the MATLAB workspace or in a model workspace.

Use signal objects to assign or validate signal or discrete state attributes by giving the signal or discrete state the same name as the workspace variable that references the Simulink.Signal object.

Signal Specification Block: An Alternative to Simulink.Signal

You can use a Signal Specification block rather than a Simulink.Signal object to assign properties left unspecified by a signal source. Each technique has advantages and disadvantages:

Using a signal object simplifies the model and allows you to change signal property values without editing the model, but does not show signal property values directly in the block diagram.

Using a Signal Specification block displays signal property values directly in the block diagram, but complicates the model and requires editing it to change signal property values.

You can use a Signal Specification block with virtual and nonvirtual buses; you can use only nonvirtual buses with a Simulink.Signal object.

The following two models illustrate the respective advantages of the two ways of assigning attributes to a signal.

7-210

Simulink.Signal

In the first example, the signal object named Sig1 specifies the sample time and data type of the signal emitted by input port In1.

To determine the properties of the Sig1 signal, you can view the signal object in the Model Explorer. In this model, the sample time is -1 and the data type is auto.

Using a signal object to specify the sample time and data type properties of signal Sig1 allows you to change the sample time or data type without having to edit the model. For example, you could use the Model Explorer, the MATLAB command line, or a MATLAB program to change these properties.

The second example uses a Signal Specification block specifies the sample time and data type of the signal emitted by input port In2. The Signal Specification block displays the data type and signal sample time properties right in the diagram, which in this case are uint8 and 4, respectively.

7-211

Simulink.Signal

Using Signal Objects to Assign or Validate Signal Attributes

This section describes how you can use signal objects to assign or validate signal attributes. The same techniques work with discrete states also. To use a signal object to assign or validate signal attribute values:

1Create a Simulink.Signal object that has the same name as the signal to which you want to assign attributes or whose attributes you want to validate.

a Open the Model Explorer.

bIn the Model Hierarchy pane, select either the Base workspace or Model workspace node, depending on the context you want for the signal object. If you create the signal object in a model workspace, you must set the Storage class parameter to Auto.

cSelect Add > Simulink Signal.

2Set the properties of the object that correspond to the attributes left unspecified by the signal source, or that correspond to the attributes you want to validate. See “Property Dialog Box” on page 7-215 for details.

3Enable explicit or implicit signal resolution:

Explicit resolution: In the Signal Properties dialog box for the signal, enable Signal name must resolve to Simulink signal object. This is the preferred technique. See “Explicit and Implicit Symbol Resolution” for more information.

Implicit resolution: Set the Configuration Parameters > Diagnostics > Data Validity > Signal resolution option for

7-212

Simulink.Signal

the model to Explicit and implicit or Explicit and warn implicit. Explicit resolution is the preferred technique.

4Assign the signal object to a workspace variable.

5Associate the signal object with the source signal.

Give the signal the same name as the workspace variable that references the signal object.

You can use a variety of techniques to associate a signal object with a signal. For examples, see “Using Signal Objects to Initialize Signals and Discrete States”, “Using Signal Objects to Tune Initial Values”, and “Apply Custom Storage Classes”.

Validation

The result when a signal does not match a signal object can depend on several factors. Simulink software can validate a signal property when you update the diagram, while you run a simulation, or both. When and how validation occurs can depend on internal rules that are subject to change, and sometimes on configuration parameter settings.

Not all signal validation compares signal source attributes with signal object properties. For example, if you specify Minimum and Maximum signal values using a signal object, the signal source must specify the same values as the signal object (or inherit the values from the object) but such validation relates only to agreement between the source and the object, not to enforcement of the minimum and maximum values during simulation.

If the value of Configuration Parameters > Diagnostics > Data Validity > Simulation range checking is none (the default), Simulink does not enforce any minimum and maximum signal values during simulation, even though a signal object provided or validated them. To enforce minimum and maximum signal values during simulation, set Simulation range checking to warning or error. See “Signal Ranges” and “Diagnostics Pane: Data Validity” for more information.

7-213

Simulink.Signal

Multiple Signal Objects

You can associate a given signal object with more than one signal if the storage class of the signal object is Auto. If the storage class of the object is other than Auto, you can associate the signal object with no more than one signal.

You can associate a given signal with no more than one signal object. The signal can refer to the signal object more that once, but every reference must resolve to exactly the same signal object. Referencing two different signal objects that have exactly the same properties causes a compile-time error.

A compile-time error occurs if a model associates more than one signal object with any signal. To prevent the error, decide which object you want the signal to use, then delete or reconfigure all references to any other signal objects, so that all remaining references resolve to the chosen signal object. See “Display Signal Sources and Destinations” for a description of techniques that you can use to trace the full extent

of a signal.

7-214

Simulink.Signal

Property

Dialog

Box

Data type

 

Data type of the signal. The default entry, auto, specifies that

 

Simulink should determine the data type. Use the adjacent

 

pulldown list to specify built-in data types (for example, uint8).

 

To specify a custom data type, enter a MATLAB expression that

 

specifies the type, (for example, a base workspace variable that

 

references a Simulink.NumericType object).

7-215

Simulink.Signal

To specify a bus object as the data type for the signal object, use the Bus: <object_name> option. See “Bus Support” on page 7-220 for details about what you need to do if you specify a bus object as the data type.

Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Data type parameter. (See “Specify Data Types Using Data Type Assistant” in Simulink User’s Guide.)

Complexity

Numeric type of the signal. Valid values are auto (determined by Simulink), real, or complex.

Dimensions

Dimensions of this signal. Valid values are -1 (the default) specifying any dimensions, N specifying a vector signal of size N, or [M N] specifying an MxN matrix signal.

Dimensions mode

Dimensions mode of this signal. From the drop-down list, select

Auto — Allows variable-size and fixed-size signals.

Fixed — Allows only fixed-size signals. Does not allow variable-size signals.

Variable — Allows only variable-size signals.

Sample time

Rate at which the value of this signal should be computed. See “Specify Sample Time” for details.

Sample mode

Sample mode of this signal. Simulink ignores the setting of this field.

Minimum

Minimum value that the signal should have. The default value is [] (unspecified). Specify a finite, real, double, scalar value.

7-216

Simulink.Signal

Note If you specify a bus object as the data type for a signal, do not set the minimum value for bus data on the signal property dialog box. Simulink ignores this setting. Instead, set the minimum values for bus elements of the bus object specified as the data type. For information on the Minimum property of a bus element, see Simulink.BusElement.

Simulink uses this value in the following ways:

When updating the diagram or starting a simulation, Simulink generates an error if the signal’s initial value is less than the minimum value or if the minimum value is outside the range for the data type of the signal.

When you enable the Simulation range checking diagnostic, Simulink alerts you during simulation if the signal value is less than the minimum value (see “Simulation range checking”).

Maximum

Maximum value that the signal should have. The default value is [] (unspecified). Specify a finite, real, double, scalar value.

Note If you specify a bus object as the data type for a signal, do not set the maximum value for bus data on the signal property dialog box. Simulink ignores this setting. Instead, set the maximum values for bus elements of the bus object specified as the data type. For information on the Maximum property of a bus element, see Simulink.BusElement.

Simulink uses this value in the following ways:

When updating the diagram or starting a simulation, Simulink generates an error if the initial value of the signal is greater than the maximum value or if the maximum value is outside the range of the data type of the signal.

7-217

Simulink.Signal

When you enable the Simulation range checking diagnostic, Simulink alerts you during simulation if the signal value

is greater than the maximum value (see “Simulation range checking”).

Initial value

Signal or state value before a simulation takes its first time step. You can specify any MATLAB string expression that evaluates to a double numeric scalar value or array.

Valid:

1.5 [1 2 3] 1+0.5

foo = 1.5; s1.InitialValue = 'foo';

Invalid:

uint(1)

foo = '1.5'; s1.InitialValue = 'foo';

If you use a bus object as the data type for the signal object, set Initial value to a string containing either 0 or a MATLAB

structure that matches the bus object. See “Bus Support” on page 7-220 for details.

If the initial value evaluates to a MATLAB structure, then in the

Configuration Parameters > Diagnostics > Data Validity pane, set “Underspecified initialization detection” to simplified.

If necessary, Simulink converts the initial value to ensure type, complexity, and dimension consistency with the corresponding block parameter value. If you specify an invalid value or expression, an error message appears when you update the model.

7-218

Simulink.Signal

Also, Simulink performs range checking of the initial value. The software alerts you when the initial value of the signal lies outside a range that corresponds to its specified minimum and maximum values and data type.

Classic initialization mode: In this mode, initial value settings for signal objects that represent the following signals and states override the corresponding block parameter initial values if undefined (specified as []):

Output signals of conditionally executed subsystems and Merge blocks

Block states

Simplified initialization mode: In this mode, initial values of signal objects associated with the following blocks are ignored. The initial values of the corresponding blocks (which cannot be specified as []) are used instead.

Outport blocks of conditionally executed subsystems

Merge blocks

Units

Measurement units in which the value of this signal is expressed, (for example, inches). You can use this parameter to document this signal. Simulink ignores it during simulation.

Storage class

Storage class of this signal. For more information, see “Tunable Parameter Storage Classes”.

If you create the signal object in a model workspace, you must set the object storage class to Auto.

Alias

Alternate name for this signal. Simulink ignores this setting. This property is used for code generation.

7-219

Simulink.Signal

Alignment

 

Data alignment boundary, specified in number of bytes. The

 

starting memory address for the data allocated for the signal will

 

be a multiple of the Alignment setting. The default value is

 

-1, which specifies that the code generator should determine an

 

optimal alignment based on usage. Otherwise, specify a positive

 

integer that is a power of 2, not exceeding 128. This field is

 

intended for use by Simulink Coder software. See “Configure Data

 

Alignment for Function Implementations”. Simulink software

 

ignores this setting.

 

Description

 

Description of this signal. This field is intended for use in

 

documenting this signal. This property is used by the Simulink

 

Report Generator and for code generation.

Bus

Using Bus Objects as the Data Type

Support

Simulink.Signal supports nonvirtual buses as the output data type.

 

 

If you set the Data type of the signal object to be a bus object, then you

 

cannot associate the signal object with a non-bus signal.

 

Using Structures for the Initial Value

 

If you use a bus object as the data type, set Initial value to 0 or a

 

MATLAB structure that matches the bus object.

 

The structure you specify must contain a value for every element of the

 

bus represented by the bus object.

 

You can use the Simulink.Bus.createMATLABStruct to create a full

 

structure that corresponds to a bus.

 

You can use Simulink.Bus.createObject to create a bus object from a

 

MATLAB structure.

 

Setting Configuration Parameters to Support Using a Bus

 

Object Data Type

 

To enable the use of a bus object as the signal object data type,

 

before you start a simulation, in the Configuration Parameters >

7-220

Simulink.Signal

Properties

Diagnostics > Connectivity pane, set “Mux blocks used to create bus signals” to error. The documentation for that diagnostic explains how convert your model to handle error messages the diagnostic generates.

 

Name

Access

Description

 

 

CoderInfo

RW

Information used by Simulink Coder

 

 

 

 

for generating code for this signal. The

 

 

 

 

value of this property is an object of

 

 

 

 

Simulink.SignalCoderInfo class.

 

 

Description

RW

Description of this signal. This field is

 

 

 

 

intended for use in documenting this

 

 

 

 

signal. (Description)

 

 

DataType

RW

String specifying the data type of this

 

 

 

 

signal. (Data type)

 

 

Min

RW

Minimum value that this signal can

 

 

 

 

have. (Minimum)

 

 

Max

RW

Maximum value that this signal can

 

 

 

 

have. (Maximum)

 

 

DocUnits

RW

Measurement units used for expressing

 

 

 

 

this signal value. (Units)

 

 

Dimensions

RW

Scalar or vector specifying the

 

 

 

 

dimensions of this signal. (Dimensions)

 

 

Complexity

RW

String specifying the numeric type of

 

 

 

 

this signal. Valid values are 'auto',

 

 

 

 

'real', or 'complex'. (Complexity)

 

 

SampleTime

RW

Rate at which this signal should be

 

 

 

 

updated. (Sample time)

 

 

Sampling

RW

Sampling mode of this signal. (Sample

 

 

Mode

 

mode)

 

 

InitialValue

RW

Signal or state value before a simulation

 

 

 

 

takes its first time step. (Initial Value)

 

7-221

Simulink.SignalCoderInfo

Purpose

Description

Property

Dialog

Box

Properties

Specify information needed to generate code for signal

Simulink software creates an instance of this class for each instance of a Simulink.Signal object that it creates. Simulink software uses the Simulink.SignalCoderInfo object to store information needed to generate code for the signal specified by the Simulink.Signal object.

You can set the properties of an instance of this class via the CoderInfo property or the property dialog box of the Simulink.Signal object that uses it. For example, the following MATLAB expression sets the

StorageClass property of a Simulink.SignalCoderInfo object named mysignal.

mysignal.CoderInfo.StorageClass = 'exportedGlobal';

Use the Code Generation Options section of the Simulink.Signal property dialog box to set the StorageClass, Alias, and Alignment properties of objects of this class.

 

Name

Description

 

 

Alias

Alternate name for this signal.

 

 

Alignment

Data alignment boundary for this signal.

 

 

 

See “Configure Data Alignment for Function

 

 

 

Implementations” in the Embedded Coder

 

 

 

documentation for more information.

 

 

CustomAttributes

Custom storage class attributes of this signal.

 

 

 

See “Introduction to Custom Storage Classes”

 

 

 

in the Embedded Coder documentation for

 

 

 

more information.

 

 

CustomStorageClass

Custom storage class of this signal.

 

 

StorageClass

Storage class of this signal. For more

 

 

 

information, see “Signals” in the Simulink

 

 

 

Coder documentation.

 

7-222

Simulink.SimulationData.BlockPath

Purpose

Description

Property

Summary

Method

Summary

Fully specified Simulink block path

Simulink creates block path objects when creating dataset objects for signal logging and data store

logging. Simulink.SimulationData.Signal and

Simulink.SimulationData.DataStoreMemory objects include block path objects.

You can create a block path that you can use with the

Simulink.SimulationData.Dataset.getElement method to access a specific dataset element. If you want to create a dataset in MATLAB to use as a baseline to compare against a signal logging or data store logging dataset, then you need to create the block paths as part of that dataset.

The Simulink.SimulationData.BlockPath class is very similar to the Simulink.BlockPath class.

You do not have to have Simulink installed to use the

Simulink.SimulationDataBlockPath class. However, you must have Simulink installed to use the Simulink.BlockPath class. For Simulink environments, consider using Simulink.BlockPath instead

of Simulink.SimulationData.BlockPath. The Simulink.BlockPath class includes a method for checking the validity of block path objects, without you having to update the model diagram.

 

Name

 

Description

 

 

SubPath

 

Individual component within the block

 

 

 

 

specified by the block path

 

 

 

 

 

 

Name

Description

 

 

BlockPath

Create a block path.

 

 

convertToCell

Convert a block path to a cell array of strings.

 

 

 

 

 

 

7-223

Simulink.SimulationData.BlockPath

 

Name

Description

 

 

getBlock

Get a single block path in the model reference

 

 

 

hierarchy.

 

 

getLength

Get the length of the block path.

 

 

 

 

 

Properties

SubPath

Description

Represents an individual component within the block specified by the block path.

For example, if the block path refers to a Stateflow chart, you can use SubPath to indicate the chart signals. For example:

Block Path:

'sf_car/shift_logic'

SubPath:

'gear_state.first'

Data Type string

Access

RW

Methods

BlockPath

Purpose

Create block path

Syntax

blockpath_object blockpath_object blockpath_object blockpath_object

=Simulink.SimulationData.BlockPath()

=Simulink.SimulationData.BlockPath(blockpath)

=Simulink.SimulationData.BlockPath(paths)

=Simulink.SimulationData.BlockPath(paths, subpath)

7-224

Simulink.SimulationData.BlockPath

Input Arguments

blockpath

The block path object that you want to copy.

paths

A string or cell array of strings that Simulink uses to build the block path.

Specify each string in order, from the top model to the specific block for which you are creating a block path.

Each string must be a path to a block within the Simulink model. The block must be:

A block in a single model

A Model block (except for the last string, which may be a block other than a Model block)

A block that is in a model that is referenced by a Model block that is specified in the previous string

subpath

A string that represents an individual component within a block.

Output Arguments

blockpath_object

The block path that you create.

Description

blockpath_object = Simulink.SimulationData.BlockPath() creates an empty block path.

blockpath_object =

Simulink.SimulationData.BlockPath(blockpath) creates a copy of the block path of the block path object that you specify with

the source_blockpath argument.

blockpath = Simulink.SimulationData.BlockPath(paths) creates a block path from the string or cell array of strings that you specify

7-225

Simulink.SimulationData.BlockPath

with the paths argument. Each string represents a path at a level of model hierarchy.

blockpath = Simulink.SimulationData.BlockPath(paths, subpath) creates a block path from the string or cell array of strings that you specify with the paths argument and creates a path for the individual component (for example, a signal) of the block.

Example

Create a block path object called bp1, using a cell array of strings representing elements of the block path.

bp1 = Simulink.SimulationData.BlockPath(...

{'sldemo_mdlref_depgraph/thermostat', ...

'sldemo_mdlref_heater/Fahrenheit to Celsius', ...

'sldemo_mdlref_F2C/Gain1'})

The resulting block path reflects the model reference hierarchy for the block path.

bp1 =

Simulink.BlockPath

Package: Simulink

Block Path: 'sldemo_mdlref_depgraph/thermostat'

'sldemo_mdlref_heater/Fahrenheit to Celsius' 'sldemo_mdlref_F2C/Gain1

convertToCell

Purpose

Convert block path to cell array of strings

Syntax

cellarray = Simulink.SimulationData.BlockPath.convertToCell()

7-226

Simulink.SimulationData.BlockPath

Output Arguments

cellarray

The cell array of strings representing the elements of the block path.

Description cellarray =

Simulink.SimulationData.BlockPath.convertToCell() converts a block path to a cell array of strings.

Examples

bp1 = Simulink.SimulationData.BlockPath(...

{'sldemo_mdlref_depgraph/thermostat', ...

'sldemo_mdlref_heater/Fahrenheit to Celsius', ...

'sldemo_mdlref_F2C/Gain1'})

cellarray_for_bp1 = bp1.convertToCell()

The result is a cell array representing the elements of the block path.

cellarray_for_bp1 =

'sldemo_mdlref_depgraph/thermostat' 'sldemo_mdlref_heater/Fahrenheit to Celsius' 'sldemo_mdlref_F2C/Gain1'

getBlock

Purpose

Get single block path in model reference hierarchy

Syntax

block = Simulink.SimulationData.BlockPath.getBlock(index)

Input Arguments

index

The index of the block for which you want to get the block path. The index reflects the level in the model reference hierarchy. An index of 1 represents a block in the top-level model, an index of 2 represents a block in a model referenced by the block of index

7-227

Simulink.SimulationData.BlockPath

1, and an index of n represents a block that the block with index n-1 references.

Output Arguments

block

The block representing the level in the model reference hierarchy specified by the index argument.

Description

blockpath =

Simulink.SimulationData.BlockPath.getBlock(index) returns the block path of the block specified by the index argument.

Example

Get the block for the second level in the model reference hierarchy.

bp1 = Simulink.SimulationData.BlockPath(...

{'sldemo_mdlref_depgraph/thermostat', ...

'sldemo_mdlref_heater/Fahrenheit to Celsius', ...

'sldemo_mdlref_F2C/Gain1'})

blockpath = bp1.getBlock(2)

The result is the thermostat block, which is at the second level in the block path hierarchy.

blockpath =

sldemo_mdlref_heater/Fahrenheit to Celsius

getLength

Purpose

Get length of block path

Syntax

length = Simulink.SimulationData.BlockPath.getLength()

7-228

Simulink.SimulationData.BlockPath

Output Arguments

length

The length of the block path. The length is the number of levels in the model reference hierarchy.

Description

length = Simulink.SimulationData.BlockPath.getLength() returns a numeric value that corresponds to the number of levels in the model reference hierarchy for the block path.

Example

Get the length of block path bp1.

bp1 = Simulink.SimulationData.BlockPath(...

{'sldemo_mdlref_depgraph/thermostat', ...

'sldemo_mdlref_heater/Fahrenheit to Celsius', ...

 

'sldemo_mdlref_F2C/Gain1'})

 

length_bp1 = bp1.getLength()

 

The result reflects that the block path has three elements.

 

length_bp1 =

 

3

See Also

Simulink.BlockPath | Simulink.SimulationData.Dataset

How To

• “Specify the Instance That Has Normal Mode Visibility”

7-229

Simulink.SimulationData.Dataset

Purpose

Container for logged data using MATLAB timeseries objects

Description Simulink creates Simulink.SimulationData.Dataset objects to store data elements when:

Performing signal logging, if you use the default signal logging format of Dataset

Logging a data store

Using the Dataset format for signal logging offers several advantages, compared to the ModelDataLogs format. For a discussion of those advantages, see “Signal logging format”.

Simulink.SimulationData.Dataset provides a getElement method for accessing individual elements in the dataset. You can specify an element by index, name, or block path.

To select the Dataset format for signal logging, use one of these approaches:

Set the Configuration Parameters > Data Import/Export > Signal logging format parameter to Dataset. For details, see “Signal logging format”.

From the MATLAB command line, set the SignalLoggingSaveFormat parameter to Dataset.

Unlike the handle-based ModelDataLogs class,

Simulink.SimulationData.Dataset is a value class. For details, see “Handle Versus Value Classes”.

If you have logged signal data in the ModelDataLogs format, you can

use the Simulink.ModelDataLogs.convertToDataset function to update the ModelDataLogs data to Dataset format.

Simulink checks signal logging data format consistency for certain model referencing configurations. For details, see “Model Reference Signal Logging Format Consistency”. You can use the Upgrade Advisor (with the upgradeadvisor function) to upgrade a model to use Dataset format.

7-230

Simulink.SimulationData.Dataset

Property

Summary

Method

Summary

An alternative approach for handling reported inconsistencies is to

use the Simulink.SimulationData.updateDatasetFormatLogging function to update the models to use Dataset format. This approach sets the Model Configuration Parameters > Data Import/Export > Signal logging format parameter to Dataset for each referenced model and each variant.

If you have logged signal data in the ModelDataLogs format, you can

use the Simulink.ModelDataLogs.convertToDataset function to convert the ModelDataLogs data to Dataset format.

For details about migrating an existing model that uses ModelDataLogs format to use Dataset format, see “ Migrate from ModelDataLogs to Dataset Format”.

 

Name

 

Description

 

 

Name

 

Logged dataset name.

 

 

 

 

 

 

Name

Description

 

 

addElement

Add an element to the end of a dataset.

 

 

get

Get element or collection of elements from the

 

 

The getElement

dataset, based on index, name, or block path.

 

 

 

 

 

 

method uses the

 

 

 

 

same syntax and

 

 

 

 

behavior as the get

 

 

 

 

method

 

 

 

 

getLength

Get number of elements in the dataset.

 

 

setElement

Change the element stored at the specified

 

 

 

index

 

7-231

Simulink.SimulationData.Dataset

Properties

Name

Description

The name of the dataset. The default is an empty string.

Specify a name when you want to easily distinguish one dataset from another. For example, if you have signal logging in model reference hierarchy, name the signal logging dataset for each model to make the output easier to analyze.

The following example shows how to give a dataset the name of

Dataset1.

ds = Simulink.SimulationData.Dataset ds.Name = 'Dataset1'

Data Type string

Access

RW

Methods

addElement

Purpose

Add element to end of dataset.

Syntax

dataset = dataset.addElement(element) dataset = dataset.addElement(element,name)

Input Arguments

element

The element to add to the dataset. The element must be one of the following:

Simulink.SimulationData.Signal object

Simulink.SimulationData.DataStoreMemory object

7-232

Simulink.SimulationData.Dataset

name

A string specifying a name for the element.

Output Arguments

dataset

The dataset to which you add the element. The new element is added to the end of the dataset.

Description

dataset =

Simulink.SimulationData.Dataset.addElement(element) adds an element to the Simulink.SimulationData.Dataset dataset.

dataset =

Simulink.SimulationData.Dataset.addElement(element, name) adds an element to the Simulink.SimulationData.Dataset dataset. This element receives the name that you specify with the name argument. You can use name to identify an element that does not have a name. If an object that already has a name (for example, a

Simulink.SimulationData.Signal object to which you assigned a name), the element uses that name unless you specify a different name by using with the name argument.

Examples

Create a dataset and add three elements to that dataset.

time = 0.1*(0:100)';

ds = Simulink.SimulationData.Dataset; element1 = Simulink.SimulationData.Signal; element1.Name = 'A';

element1.Values = timeseries(sin(time), time); ds = ds.addElement(element1);

element2 = Simulink.SimulationData.Signal; element2.Name = 'B';

element2.Values = timeseries(2*sin(time), time); ds = ds.addElement(element2);

element3 = Simulink.SimulationData.Signal; element3.Name = 'C';

7-233

Simulink.SimulationData.Dataset

element3.Values = timeseries(3*sin(time), time); ds = ds.addElement(element3)

The output is:

ds =

Simulink.SimulationData.Dataset

Package: Simulink.SimulationData

Characteristics:

Name: 'topOut'

Total Elements: 3

Elements:

1:'A'

2:'B'

3:'C'

get

Purpose

Get element or collection of elements from dataset, based on index, name, or block path

The getElement method shares the same syntax and behavior as the get method.

Syntax

element = dataset.get(search_arg)

element = dataset.get(search_arg,'-blockpath')

Input Arguments

search_arg

The index, name, or block path that identifies the element to access. To access an element by:

Index — Set search_arg to a scalar numeric value.

7-234

Simulink.SimulationData.Dataset

Name — Set search_arg to a character array.

Block path — Specify a Simulink.SimulationData.BlockPath object. For signal logging, specify the blockpath for the source block for the element.

When specifying a name or block path for search_arg in cases where there could be duplicate names or block paths, use a cell array to consistently return a

Simulink.SimulationData.Dataset object. (Such duplication could occur, for example, in a model reference hierarchy.)

'-blockpath'

Specify a block path directly. Set search_arg to a character array representing the full block path to the element, followed by '-blockpath'.

Output Arguments

element

The element that the getElement method adds to the dataset. The returned value depends on the search_arg format.

 

search_arg Argument Value

Returned Value

 

 

Single-character array or

Single element if only one element is found;

 

 

Simulink.SimulationData.BlockPath

dataset if more than one element with the

 

 

object

specified name exists

 

 

Cell array containing one string or

Dataset

 

 

Simulink.SimulationData.BlockPath

 

 

 

object

 

 

Description

element = Simulink.SimulationData.Dataset.get(search_arg) returns the element corresponding the index, name, or block path that you specify with search_arg.

element = Simulink.SimulationData.Dataset.get(search_arg, '-blockpath') returns the element corresponding the search_arg

7-235

Simulink.SimulationData.Dataset

character array that identifies the block path for the element that you want to access.

Examples

Access dataset elements in the top model of the sldemo_mdlref_bus model. The signal logging dataset is topOut.

sldemo_mdlref_bus sim('sldemo_mdlref_bus') topOut

The output is:

topOut =

Simulink.SimulationData.Dataset

Package: Simulink.SimulationData

Characteristics:

Name: 'topOut'

Total Elements: 4

Elements:

1:'COUNTERBUS'

2:'OUTPUTBUS'

3:'INCREMENTBUS'

4:'inner_bus'

-Use get or getElement to access elements by index, name or block path. -Use addElement or setElement to add or modify elements.

Methods, Superclasses

Access the first element of the dataset, by specifying an index for search_arg.

element1 = topOut.get(1)

7-236

Simulink.SimulationData.Dataset

Access the second element of the dataset, by using a cell array to specify the name for search_arg.

element2 = topOut.get({'OUTPUTBUS'})

Access the third element of the dataset by block path. In the Simulink Editor, select the IncrementBusCreator block. At the MATLAB command line, use gcb for search_arg and use the '-blockpath' argument.

element3 = topOut.get(gcb,'-blockpath')

getLength

Purpose

Get number of elements in dataset.

Syntax

length = Simulink.SimulationData.Dataset.getLength()

Description

length = Simulink.SimulationData.Dataset.getLength() Get the number of elements in the top-level dataset. To get the number of elements of a nested dataset, use getLength with the nested dataset.

Example

Get the number of elements in the signal logging dataset for the sldemo_mdlref_demo.

length = topOut.getLength()

setElement

Purpose

Change element stored at specified index.

7-237

Simulink.SimulationData.Dataset

Syntax

dataset = Simulink.SimulationData.Dataset.setElement(index,...

element)

dataset = Simulink.SimulationData.Dataset.setElement(index,...

element,name)

Input Arguments

index

A scalar numeric value specifying the index for the added element. The value must be between 1 and the number of elements plus 1.

element

The element to replace an existing element or to add to the dataset. The element must be one of the following:

Simulink.SimulationData.Signal object

Simulink.SimulationData.DataStoreMemory object

name

A string specifying a name for the element.

Output Arguments

dataset

The dataset in which you change or add an element.

Description

dataset = Simulink.SimulationData.Dataset.setElement(index, element) Change the element stored at the specified index, for an existing index. If index is one greater than the number of elements in the dataset, the element is added at the end of the dataset.

dataset = Simulink.SimulationData.Dataset.setElement(index, element, name) changes the element stored at the specified index and gives it the name that you specify with the name argument. You can use name to identify an element that does not have a name. If an object that already has a name (for example, a Simulink.SimulationData.Signal object to which you assigned a name), the element uses that name unless you specify a different name by using with the name argument.

7-238

Simulink.SimulationData.Dataset

Example

ds = Simulink.SimulationData.Dataset element1 = Simulink.SimulationData.Signal element1.Name = 'A'

ds = ds.addElement(element1)

element2 = Simulink.SimulationData.Signal element2.Name = 'B'

elementNew = Simulink.SimulationData.Signal ds = ds.setElement(2,elementNew,'B1')

ds

The output is:

ds =

Simulink.SimulationData.Dataset

Package: Simulink.SimulationData

Characteristics:

Name: 'topOut'

Total Elements: 2

Elements:

1:'A'

2:'B1'

Use getElement to access elements by index, name or block path.

Methods, Superclasses

See Also Simulink.SimulationData.BlockPath

| Simulink.SimulationData.Signal |

Simulink.SimulationData.DataStoreMemory |

Simulink.ModelDataLogs

How To

“Specify the Signal Logging Data Format”

 

“Export Signal Data Using Signal Logging”

7-239

Simulink.SimulationData.Dataset

• “Log Data Stores”

7-240

Simulink.SimulationData.DataStoreMemory

Purpose

Description

Property

Summary

Properties

Container for data store logging information

Simulink uses Simulink.SimulationData.DataStoreMemory objects to store logging information from Data Store Memory blocks during simulation. The objects contain information about the blocks that write to the data store.

 

Name

Description

 

 

BlockPath

Location of Data Store Memory block for

 

 

 

the logged data store

 

 

DSMWriterBlockPaths

Location of Data Store Write blocks that

 

 

 

write to the data store

 

 

DSMWriters

Data Store Write blocks for each signal

 

 

 

value

 

 

Name

Name of the data store dataset

 

 

Scope

Scope of the data store: 'local' or

 

 

 

'global'

 

 

Values

Time and data that were logged

 

 

 

 

 

BlockPath

Description

Location of Data Store Memory block for the logged data store.

Data Type string

Access

RW

7-241

Simulink.SimulationData.DataStoreMemory

DSMWriterBlockPaths

Description

Location of blocks that write to the data store. Each element of the array contains the full block path of one writer block.

Data Type

Vector of Simulink.SimulationData.BlockPath objects

Access

RO

DSMWriters

Description

The number of writes in the data store.

The nth element of DSMWriters contains the index of the element in DSMWriterBLockPaths that contains the block path of the writer that performed the nth write to Values.

Data Type

Integer vector

Access

RO

Name

Description

Name of the data store dataset

Data Type string

Access

RO

7-242

Simulink.SimulationData.DataStoreMemory

Scope

Description

Scope of the data store: 'local' or 'global'

Data Type string

Access

RW

Values

Description

Time and data that were logged

Data Type

MATLAB timeseries

Access

RW

See Also Simulink.SimulationData.Dataset |

Simulink.SimulationData.BlockPath | Data Store Memory |

Data Store Write

How To

• “Log Data Stores”

7-243

Simulink.SimulationData.LoggingInfo

Purpose

Description

Property

Summary

Method

Summary

Properties

Signal logging override settings

This object specifies a set of signal logging override settings.

Use a Simulink.SimulationData.LoggingInfo object to specify the signal logging override settings for a signal. You can use this object for the LoggingInfo property of a

Simulink.SimulationData.SignalLoggingInfo object.

 

Name

Description

 

 

DataLogging

Signal logging mode.

 

 

NameMode

Source of signal logging name.

 

 

LoggingName

Custom signal logging name.

 

 

DecimateData

Use interval for logging data points.

 

 

Decimation

Decimation value (M): Simulink logs every

 

 

 

Mth data point.

 

 

LimitDataPoints

Limit number of data points to log.

 

 

MaxPoints

Maximum number of data points to log

 

 

 

(N). The set of logged data points is the last

 

 

 

N data points generated by the simulation.

 

 

Name

Description

 

 

LoggingInfo

Create a set of signal logging override settings

 

 

 

for a signal.

 

 

 

 

 

 

DataLogging

 

 

 

Description

 

 

 

Signal logging mode.

 

 

Indicates whether logging is enabled for this signal.

7-244

Simulink.SimulationData.LoggingInfo

Data Type

logical value — {true} | false

Access

RW

NameMode

Description

Source of signal logging name.

Indicates whether the signal logging name is a custom name ('true') or whether the signal logging name is the same as the signal name

('false').

Data Type

logical value — true | {false}

Access

RW

LoggingName

Description

Custom signal logging name

The custom signal logging name to use for this signal, if the NameMode property is true.

Data Type string

Access

RW

DecimateData

Description

Log a subset of sample points, selecting data points at a specified interval.

7-245

Simulink.SimulationData.LoggingInfo

Data Type

logical value — true | {false}

Access

RW

Decimation

Description

Decimation value (M). If the DecimateData property is true, then Simulink logs every Mth data point.

Data Type nonzero integer

Access

RW

LimitDataPoints

Description

Limit the number of data points to log.

Data Type

logical value — true | {false}

Access

RW

MaxPoints

Description

Maximum number of data points to log (N). If the LimitDataPoints property is true, then the set of logged data points includes the last N data points generated by the simulation.

Data Type nonzero integer

Access

RW

7-246

Simulink.SimulationData.LoggingInfo

Methods

LoggingInfo

Purpose

Create a Simulink.SimulationData.LoggingInfo object.

Syntax

logging_info_object = Simulink.SimulationData.LoggingInfo() logging_info_object = Simulink.SimulationData.LoggingInfo(object)

Input Arguments

object

A signal logging override settings object whose property values the constructor uses for the new

Simulink.SimlationData.LoggingInfo object. The signal logging override object that you specify can be either of the following types of objects:

Simulink.SimulationData.LoggingInfo object

Simulink.LoggingInfo object

Output Arguments logging_info_object

A Simulink.SimulationData.LoggingInfo object.

Description

logging_info_object = Simulink.SimulationData.LoggingInfo() creates a Simulink.SimulationData.LoggingInfo object that has default property values.

logging_info_object =

Simulink.SimulationData.LoggingInfo(object) creates a Simulink.SimulationData.LoggingInfo object that copies the property values from the signal logging override object that you specify with the object argument.

Examples

The following example creates a

Simulink.SimulationData.LoggingInfo object with default settings, changes the DecimateData and Decimation properties,

7-247

Simulink.SimulationData.LoggingInfo

and uses the object for the LoggingInfo property of a

Simulink.SimulationData.SignalLoggingInfo object mi.

log_info = Simulink.SimulationData.LoggingInfo(); log_info.DecimateData = true;

log_info.Decimation = 2;

mi = Simulink.SimulationData.SignalLoggingInfo('sldemo_mdlref_bus'); mi.LoggingInfo = log_info

Simulink.SimulationData.SignalLoggingInfo

Package: Simulink.SimulationData

BlockPath:

'sldemo_mdlref_bus'

OutputPortIndex: 1

LoggingInfo:

DataLogging: 1

NameMode: 0

LoggingName: ''

DecimateData: 1

Decimation: 2

LimitDataPoints: 0

MaxPoints: 5000

See Also Simulink.SimulationData.ModelLoggingInfo |

Simulink.SimulationData.SignalLoggingInfo

| Simulink.SimulationData.BlockPath

| Simulink.SimulationData.Signal |

Simulink.SimulationData.DataStoreMemory |

Simulink.ModelDataLogs

How To

“Command-Line Interface for Overriding Signal Logging Settings”

 

“Specify the Signal Logging Data Format”

 

“Export Signal Data Using Signal Logging”

7-248

Simulink.SimulationData.LoggingInfo

• “Log Data Stores”

7-249

Simulink.SimulationData.ModelLoggingInfo

Purpose

Description

Signal logging override settings for a model

This class is a collection of

Simulink.SimulationData.SignalLoggingInfo objects that specify all signal logging override settings for a model.

Use methods and properties of this class to:

Turn off logging for a signal or a Model block.

Change logging settings for any signals that are already marked for logging within a model.

You can control whether a top-level model and referenced models use override signal logging settings or use the signal logging settings specified by the model. Use the LoggingMode and LogAsSpecifiedByModels properties to control which logging settings to apply.

 

Logging Mode for

Property Settings

 

 

Models

 

 

 

For top-level model and

Set LoggingMode to

 

 

all referenced models, use

LogAllAsSpecifiedInModel.

 

 

logging settings specified

 

 

 

in the model.

 

 

 

For top-level model and

Set LoggingMode to OverrideSignals.

 

 

all referenced models, use

 

 

 

override signal logging

 

 

 

settings.

 

 

 

For top-level model and

Set LoggingMode to OverrideSignals.

 

 

referenced models, use

In the LogAsSpecifiedByModels cell

 

 

a mix of override signal

 

 

array, include the models that you do not

 

 

logging settings and the

 

 

want to use the override signal logging

 

 

signal logging settings

 

 

settings.

 

 

specified in the model.

 

 

 

 

 

 

 

 

7-250

Simulink.SimulationData.ModelLoggingInfo

Property

Summary

Method

Summary

Properties

 

Name

Description

 

 

LoggingMode

Signal logging override status

 

 

LogAsSpecifiedByModels

Source of signal logging settings for the

 

 

 

top-level model or a top-level Model block

 

 

Signals

All signals that have signal override

 

 

 

settings

 

 

Name

Description

 

 

findSignal

Find signals within the Signals

 

 

 

vector, using block path and output

 

 

 

port index.

 

 

verifySignalAndModelPaths

Verify signal and model paths for the

 

 

 

model signal logging override object.

 

 

getLogAsSpecifiedInModel

Determine whether the model logs

 

 

 

signals as specified in the model or

 

 

 

uses override settings.

 

 

setLogAsSpecifiedInModel

Set the logging mode for the top-level

 

 

 

model or a top-level Model block.

 

 

createFromModel

Create and populate a model signal

 

 

 

logging override object with all

 

 

 

logged signals in the model reference

 

 

 

hierarchy.

 

 

ModelLoggingInfo

Set signals to log or override logging

 

 

 

settings.

 

LoggingMode

Description

Signal logging override status. Values are:

7-251

Simulink.SimulationData.ModelLoggingInfo

OverrideSignals — (Default) Uses the logging settings for signals, as specified in the Signals property. For models where getLogAsSpecifiedInModel is:

-

-

true — Logs all signals, as specified in the model.

false — Logs only the signals specified in the Signals property.

LogAllAsSpecifiedInModel — Logs signals in the top-level model and all referenced models, as specified in the model. Simulink honors the signal logging indicators (blue antennae) and ignores the Signals property.

To change the logging mode for the top-level model or for a given reference model, use the setLogAsSpecifiedInModel method.

Data Type

logical value — true or false

Access

RW

LogAsSpecifiedByModels

Description

When LoggingMode is set to 'OverrideSignals', this cell array specifies whether the top-level model or a top-level Model block logs all signals based on the signal logging settings defined in the model.

For the top-level model and top-level Model blocks that the cell array includes, Simulink ignores the Signals property overrides.

For a model or Model block that the cell array does not include, Simulink uses the Signals property to determine which signals to log.

When LoggingMode is set to 'LogAllAsSpecifiedInModel', Simulink ignores the LogAsSpecifiedByModels property.

Use the getLogAsSpecifiedInModel method to determine whether the top-level model or top-level Model block logs signals as specified in the

7-252

Simulink.SimulationData.ModelLoggingInfo

model (default logging), and use setLogAsSpecifiedInModel to turn default logging on and off.

Data Type

cell array — For the top-level model, specify the model name. For Model blocks, specify the block path.

Access

RW

Signals

Description

Vector of Simulink.SimulationData.SignalLoggingInfo objects for all signals with signal logging override settings.

Data Type

vector of Simulink.SimulationData.SignalLoggingInfo objects

Access

RW

Methods

createFromModel

Purpose

Create a Simulink.SimulationData.ModelLoggingInfo object for a top-level model, with override settings for each logged signal in the model.

Syntax

model_logging_info_object = ...

Simulink.SimulationData.ModelLoggingInfo.createFromModel(...

model, options)

Input Arguments

model

Name of the top-level model for which to create a

Simulink.SimulationData.ModelLoggingInfo object.

7-253

Simulink.SimulationData.ModelLoggingInfo

options

You can use any combination of the following option name and value pairs to control the kinds of systems from which to include logged signals.

FollowLinks

on — (Default) Include logged signals from inside of libraries.

off — Skip all libraries.

LookUnderMasks

all — (Default) Include logged signals from all masked subsystems.

none — Skip all masked subsystems.

graphical — Include logged signals from masked subsystems that do not have a workspace or dialog box.

functional — Include logged signals from masked subsystems that do not have a dialog box.

Variants

ActiveVariants — (Default) Include logged signals from only active subsystem and model reference variants.

AllVariants — Include logged signals from all subsystem and model reference variants.

RefModels

on — (Default) Include logged signals from referenced models.

off — Skip all referenced models.

If you select more than one option, then the created

Simulink.SimlationData.ModelLoggingInfo object includes signals that fit the combinations (the “AND”) of the specified options. For example, if you set FollowLinks to on and set

7-254

Simulink.SimulationData.ModelLoggingInfo

RefModels to off, then the model signal logging override object does not include signals from library links that exist inside of referenced models.

Output Arguments model_logging_override_object

Simulink.SimulationData.ModelLoggingInfo object for the top-level model.

Description

model_logging_info_object =

Simulink.SimulationData.ModelLoggingInfo.createFromModel(model) creates a Simulink.SimulationData.ModelLoggingInfo object for the model that includes logged signals for the following kinds of systems:

Libraries

Masked subsystems

Referenced models

Active variants

model_logging_override_object = Simulink.SimulationData.ModelLoggingInfo.createFromModel(model,

options) creates a Simulink.SimulationData.ModelLoggingInfo object for the model. The included logged signals reflect the options settings for the following kinds of systems:

Libraries

Masked subsystems

Referenced models

Variants

Examples

The following example creates a model logging override object for the sldemo_mdlref_bus model and automatically adds each logged signal in the model to that object:

7-255

Simulink.SimulationData.ModelLoggingInfo

mi = Simulink.SimulationData.ModelLoggingInfo.createFromModel(...

'sldemo_mdlref_bus')

mi =

Simulink.SimulationData.ModelLoggingInfo

Package: Simulink.SimulationData

Properties:

Model: 'sldemo_mdlref_bus'

LoggingMode: 'OverrideSignals'

LogAsSpecifiedByModels: {}

Signals: [1x4 Simulink.SimulationData.SignalLoggingInfo]

Methods

The following example explicitly specifies the kinds of systems from which to include signals, rather than use the default settings for each kind of system. This example specifies to include signals from all model reference variants (instead of using the default of including only active variant).

The sldemo_mdlref_variants model has two variants:

sldemo_mrv_nonlinear_controller and sldemo_controller. In this example, in each variant, you configure a signal for signal logging, and

then create a Simulink.SimulationData.ModelLoggingInfo object. The resulting object includes, in the Signals property, two signals (one from each variant).

sldemo_mrv_nonlinear_controller; sldemo_mrv_second_order_controller;

ph = get_param('sldemo_mrv_nonlinear_controller/Add','PortHandles'); set_param(ph.Outport(1),'DataLogging','on');

ph1 = get_param('sldemo_mrv_second_order_controller/Add','PortHandles'); set_param(ph1.Outport(1),'DataLogging','on');

mi = Simulink.SimulationData.ModelLoggingInfo.createFromModel(...

'sldemo_mdlref_variants', 'Variants', 'AllVariants')

7-256

Simulink.SimulationData.ModelLoggingInfo

Results:

V_NONLINEAR_CONTROLLER =

Simulink.Variant

Condition: 'CTRL==1'

V_SECOND_ORDER_CONTROLLER =

Simulink.Variant

Condition: 'CTRL==2'

CTRL =

1

mi =

Simulink.SimulationData.ModelLoggingInfo

Package: Simulink.SimulationData

Properties:

Model: 'sldemo_mdlref_variants'

LoggingMode: 'OverrideSignals'

LogAsSpecifiedByModels: {}

Signals: [1x2 Simulink.SimulationData.SignalLoggingInfo]

Methods

ModelLoggingInfo

Purpose

Specify signals to log or override logging settings.

Syntax

model_logging_override_object = ....

7-257

Simulink.SimulationData.ModelLoggingInfo

Simulink.SimulationData.ModelLoggingInfo(model)

Input Arguments

model

Name of the top-level model for which to create a

Simulink.SimulationData.ModelLoggingInfo object

Output Arguments model_logging_override_object

Simulink.SimulationData.ModelLoggingInfo object created for the specified top-level model.

Description

model_logging_override_object=

Simulink.SimulationData.ModelLoggingInfo(model) creates a Simulink.SimulationData.ModelLoggingInfo object for the specified top-level model.

If you use the Simulink.SimulationData.ModelLoggingInfo

constructor, specify a Simulink.SimulationData.SignalLoggingInfo object for each logged signal for which you want to override logging settings.

To check that you have specified valid signal logging override settings for a model, use the verifySignalAndModelPaths method with the

Simulink.SimulationData.ModelLoggingInfo object for the model.

Examples

The following example shows how to log all signals as specified in the top-level model and all referenced models.

mi = Simulink.SimulationData.ModelLoggingInfo('sldemo_mdlref_bus'); mi.LoggingMode = 'LogAllAsSpecifiedInModel'

mi =

Simulink.SimulationData.ModelLoggingInfo

Package: Simulink.SimulationData

7-258

Simulink.SimulationData.ModelLoggingInfo

Properties:

Model: 'sldemo_mdlref_bus'

LoggingMode: 'LogAllAsSpecifiedInModel'

LogAsSpecifiedByModels: {}

Signals: []

Methods

set_param('sldemo_mdlref_bus', 'DataLoggingOverride', mi);

The following example shows how to log only signals in the top-level model:

mi = ...

Simulink.SimulationData.ModelLoggingInfo('sldemo_mdlref_bus');

mi.LoggingMode = 'OverrideSignals';

mi = mi.setLogAsSpecifiedInModel('sldemo_mdlref_bus', true);

set_param('sldemo_mdlref_bus', 'DataLoggingOverride', mi);

findSignal

Purpose

Find signals within the Signals vector, using a block path and optionally an output port index.

Syntax

signal_indices = ...

model_logging_override_object.findSignal(block_path)

signal_indices = ...

model_logging_override_object.findSignal(...

block_path, port_index)

Input Arguments

block_path

Source block to search. The block_path must be one of the following:

String

7-259

Simulink.SimulationData.ModelLoggingInfo

Cell array of strings

Simulink.BlockPath object

port_index

Index of the output port to search. Specify a scalar greater than, or equal to, 1.

Output Arguments

signal_indices

Vector of numeric indices into the signals vector of the

Simulink.SimulationData.ModelLoggingInfo object.

Description

signal_indices =

model_logging_override_object.findSignal(block_path) finds the indices of the signals for the block path that you specify.

To find a single instance of a signal within a referenced model, use a Simulink.BlockPath object or a cell array with a full path.

To find all instances of a signal within a referenced model, use a string with the relative path of the signal within the referenced model.

To find a logged chart signal within a Stateflow chart, use a Simulink.BlockPath object and set the SubPath property to the name of the Stateflow chart signal.

signal_indices =

model_logging_override_object.findSignal(block_path, port_index) finds the indices of the output signal for the port that you specify, for the block path that you specify.

Do not use the port_index argument for Stateflow chart signals.

Examples

To find a signal that is not in a Stateflow chart and that does not appear in multiple instances of a referenced model:

sldemo_mdlref_bus

% Open the referenced model

7-260

Simulink.SimulationData.ModelLoggingInfo

sldemo_mdlref_counter_bus

mi = Simulink.SimulationData.ModelLoggingInfo.createFromModel(...

'sldemo_mdlref_bus');

%Click the Bus Creator block that is the source of

%the logged COUNTERBUS signal

signal_index = mi.findSignal(gcb)

The output is:

signal_index =

4

As an alternative in the above example, you could issue the gcb function and use its output string with the findSignal method:

gcb

ans =

sldemo_mdlref_counter_bus/Bus Creator

signal_index = mi.findSignal('sldemo_mdlref_counter_bus/Bus Creator')

To find a signal in a specific instance of a referenced model that is not in a Stateflow chart, use the following approach:

signal_index = mi.findSignal({'sldemo_mdlref_bus/CounterA', ...

'sldemo_mdlref_counter_bus/Bus Creator'})

For an example that uses the findSignal method with a Stateflow chart, see “Overriding Logging Properties with the Command-Line API” in the Stateflow documentation.

7-261

Simulink.SimulationData.ModelLoggingInfo

getLogAsSpecifiedInModel

Purpose

Determine whether the model logs as specified in the model or uses override settings.

Syntax

logging_mode = ...

getLogAsSpecifiedInModel(model_logging_override_object, path)

Input Arguments model_logging_override_object

A Simulink.SimulationData.ModelLoggingInfo object.

path

The path is a string that specifies one of the following:

Name of the top-level model

Block path of a Model block in the top-level model

Output Arguments logging_mode

The logging_mode is:

true, if the model specified by path is logged as specified in the model.

false, if the model specified by path is logged using the override settings specified in the Signals property.

Description

logging_mode =

model_logging_override_object.getLogAsSpecifiedInModel(path) returns:

true, if the model specified by path is logged as specified in the model.

false, if the model specified by path is logged using the override settings specified in the Signals property.

7-262

Simulink.SimulationData.ModelLoggingInfo

Examples

In the following example, the

Simulink.SimulationData.ModelLoggingInfo object mi uses the override settings specified in its Signals property.

mi = Simulink.SimulationData.ModelLoggingInfo('sldemo_mdlref_bus');

logging_mode = getLogAsSpecifiedInModel(mi, 'sldemo_mdlref_bus')

The output is:

logging_mode =

0

setLogAsSpecifiedInModel

Purpose

Set logging mode for top-level model or top-level Model block

Syntax

setLogAsSpecifiedInModel(override_object, path)

Input Arguments override_object

Simulink.SimulationData.ModelLoggingInfo object.

path

String that specifies one of the following:

Name of the top-level model

Block path of a Model block in the top-level model

value

Logging mode:

true, if the model specified by path is logged as specified in the model

false, if the model specified by path is logged using the override settings specified in the Signals property.

7-263

Simulink.SimulationData.ModelLoggingInfo

Description

setLogAsSpecifiedInModel(override_object, path, value) sets the LoggingMode property for a top-level model or a Model block in the top-level model.

Example

The following example shows how to log only signals in the top-level model, using the logging settings specified in that model:

mi = Simulink.SimulationData.ModelLoggingInfo('sldemo_mdlref_bus');

mi.LoggingMode = 'OverrideSignals';

setLogAsSpecifiedInModel(mi, 'sldemo_mdlref_bus', true);

set_param('sldemo_mdlref_bus', 'DataLoggingOverride', mi);

verifySignalAndModelPaths

Purpose

Verify paths in Simulink.SimulationData.ModelLoggingInfo object.

Syntax

verified_object = verifySignalAndModelPaths...

(model_logging_override_object, action)

Input Arguments model_logging_override_object

The Simulink.SimulationData.ModelLoggingInfo object to verify. This argument is required.

action

The action that the function performs if verification fails. This argument is optional. Specify one of the following values:

error — (default) Throw an error when verification fails

warnAndRemove — Issue a warning when verification fails and update the Simulink.SimulationData.ModelLoggingInfo object.

remove — Silently update the

Simulink.SimulationData.ModelLoggingInfo object.

7-264

Simulink.SimulationData.ModelLoggingInfo

Output Arguments

verified_object

If the method detects no invalid paths, it returns the validated object. For example:

verified_object =

Simulink.SimulationData.ModelLoggingInfo

Package: Simulink.SimulationData

Properties:

Model: 'logging_top'

LoggingMode: 'OverrideSignals'

LogAsSpecifiedByModels: {}

Signals: [1x11 Simulink.SimulationData.SignalLoggingInfo]

If the method detects an invalid path, it performs the action specified by the action argument. By default, it issues an error message.

Description

verified_object = verifySignalAndModelPaths(model_logging_override_object, action)

For a Simulink.SimulationData.ModelLoggingInfo object, verify that:

All strings in the LogAsSpecifiedByModels property are either the name of the top-level model or the block path of a Model block in the top-level model.

The block paths for signals in the Signals property refer to valid blocks within the hierarchy of the top-level model.

The OutputPortIndex property for all signals in the Signals property are valid for the given block.

All signals in the Signals property refer to logged signals.

7-265

Simulink.SimulationData.ModelLoggingInfo

The action argument specifies what action the method performs. By default, the method returns an error if it detects an invalid path.

If you use the Simulink.SimulationData.ModelLoggingInfo constructor and specify a

Simulink.SimulationData.SignalLoggingInfo object for each signal, then consider using the verifySignalAndModelPaths method to verify that your object definitions are valid.

Example

The following example shows how to validate the signal and block paths

in a Simulink.SimulationData.ModelLoggingInfo object. Because the action argument is warnAndRemove, if the validation fails, the verifySignalAndModelPaths method issues a warning and updates

the Simulink.SimulationData.ModelLoggingInfo object.

mi = Simulink.SimulationData.ModelLoggingInfo('sldemo_mdlref_bus');

verified_object = verifySignalAndModelPaths...

(mi, 'warnAndRemove')

See Also Simulink.BlockPath | Simulink.SimulationData.LoggingInfo

| Simulink.SimulationData.SignalLoggingInfo

| Simulink.SimulationData.Signal |

Simulink.SimulationData.DataStoreMemory |

Simulink.ModelDataLogs

How To

“Specify the Signal Logging Data Format”

 

“Export Signal Data Using Signal Logging”

 

“Log Data Stores”

7-266

Simulink.SimulationData.SignalLoggingInfo

Purpose

Description

Property

Summary

Method

Summary

Properties

Signal logging override settings for signal

This object contains the signal override signal logging settings for a single logged signal.

 

Name

Description

 

 

BlockPath

Simulink.BlockPath of source block of

 

 

 

a signal to log.

 

 

OutputPortIndex

Index of an ouput port to log.

 

 

LoggingInfo

Simulink.SimulationData.LoggingInfo

 

 

 

object containing all logging override

 

 

 

settings for a signal.

 

 

Name

Description

 

 

SignalLoggingInfo

Create a signal logging override object for a

 

 

 

signal.

 

 

 

 

 

BlockPath

Description

Simulink.BlockPath of source block of signal to log. The block path represents the full model reference hierarchy.

To specify a specific instance of a signal, use an absolute path, reflecting the model reference hierarchy, starting at the top model. For example:

sig_log_info = Simulink.SimulationData.SignalLoggingInfo(...

{'sldemo_mdlref_bus/CounterA', ...

'sldemo_mdlref_counter_bus/Bus Creator'})

Data Type

Simulink.BlockPath

7-267

Simulink.SimulationData.SignalLoggingInfo

Access

RW

OuputPortIndex

Description

Index of the output port to log. The index is a 1-based numeric value.

Data Type nonzero integer

Access

RW

LoggingInfo

Description

Simulink.SimulationData.LoggingInfo object containing logging override settings for a signal. The logging settings specify whether signal logging is overridden for this signal. The logging settings also can specify a logging name, a decimation factor, and a maximum number of data points.

Data Type cell array

Access

RW

Methods

SignalLoggingInfo

Purpose

Construct a Simulink.SimulationData.SignalLoggingInfo object.

Syntax

signal_logging_info_object = ...

Simulink.SimulationData.SignalLoggingInfo()

signal_loggingInfo_object = ...

Simulink.SimulationData.SignalLoggingInfo(path)

7-268

Simulink.SimulationData.SignalLoggingInfo

signalLoggingInfo_object = ...

Simulink.SimulationData.SignalLoggingInfo(path,index)

Input Arguments

path

The block path of the source block for which the signal logging override settings apply. If you use this argument without also using the port argument, then Simulink sets the output port index to 1.

index

Output port index to which the signal logging override settings apply.

Output Arguments signal_logging_object

Simulink.SimulationData.SignalLoggingInfo object that represents the override settings of a signal.

Description

signal_logging_override_object =

Simulink.SimulationData.SignalLoggingInfo() creates a Simulink.SimulationData.LoggingInfo object that contains default logging settings for a signal.

signal_logging_override_object =

Simulink.SimulationData.SignalLoggingInfo(path) creates a Simulink.SimulationData.LoggingInfo object, using the specified block path, and sets the output port index to 1.

signal_logging_override_object =

Simulink.SimulationData.SignalLoggingInfo(path, port) creates a Simulink.SimulationData.LoggingInfo object that contains default logging settings for the specified block path and output port index.

Examples

The following example creates a

Simulink.SimulationData.SignalLoggingInfo object for the first output port of the Bus Creator block in the sldemo_mdlref_bus model.

7-269

Simulink.SimulationData.SignalLoggingInfo

sldemo_mdlref_bus;

mi = Simulink.SimulationData.ModelLoggingInfo(...

'sldemo_mdlref_bus');

mi.LoggingMode = 'OverrideSignals';

mi.Signals = ...

Simulink.SimulationDatal.SignalLoggingInfo(...

{'sldemo_mdlref_bus/CounterA', ...

'sldemo_mdlref_counter_bus/Bus Creator'}, 1)

The output is:

mi =

Simulink.SimulationData.ModelLoggingInfo

Package: Simulink.SimulationData

Properties:

Model: 'sldemo_mdlref_bus'

LoggingMode: 'OverrideSignals'

LogAsSpecifiedByModels: {}

Signals: [1x1 Simulink.SimulationData.SignalLoggingInfo]

Methods

See Also Simulink.SimulationData.ModelLoggingInfo

| Simulink.SimulationData.LoggingInfo

| Simulink.SimulationData.BlockPath

| Simulink.SimulationData.Signal |

Simulink.SimulationData.DataStoreMemory |

Simulink.ModelDataLogs

How To

“Command-Line Interface for Overriding Signal Logging Settings”

 

“Specify the Signal Logging Data Format”

 

“Export Signal Data Using Signal Logging”

 

“Log Data Stores”

7-270

Simulink.SimulationData.Signal

Purpose

Description

Property

Summary

Properties

Container for signal logging information

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

 

Name

Description

 

 

BlockPath

Block path for the source block for the

 

 

 

signal

 

 

Name

Name of signal element to use for

 

 

 

name-based access

 

 

PortIndex

Numeric index of port that was logged

 

 

PortType

Type of port that was logged: for signal

 

 

 

logging, the port type is 'outport'

 

 

Values

Time and data that were logged

 

 

 

 

 

BlockPath

Description

Block path for the source block for the signal

Data Type

Simulink.SimulationData.BlockPath

Access

RW

Name

Description

Name of signal element to use for name-based access

7-271

Simulink.SimulationData.Signal

Data Type string

Access

RW

PortIndex

Description

Numeric index of port that was logged

Data Type string

Access

RW

PortType

Description

Type of port that was logged: for signal logging, the port type is

'outport'

Data Type string

Access

RW

Values

Description

Time and data that were logged.

For an example of how to use the Values property and plot logged signal data, in the sldemo_mdlref_bus example, see “Logging Signal Data.”

Data Type

A single MATLAB timeseries object or a MATLAB structure of timeseries objects (for bus signals)

7-272

Simulink.SimulationData.Signal

 

Access

 

RW

See Also

Simulink.BlockPath | Simulink.SimulationData.Dataset |

 

timeseries

How To

• “Access Signal Logging Data”

 

• “Import MATLAB timeseries Data”

 

• “Import Structures of timeseries Objects for Buses”

7-273

Simulink.SimulationOutput

Purpose

Description

Methods

Copy

Semantics

Examples

Access object values of simulation results

The SimulationOutput class contains all simulation outputs, including workspace variables.

Use Simulink.SimulationOutput.who and

either Simulink.SimulationOutput.get or Simulink.SimulationOutput.find methods to access the output variable names and their respective values.

find

Access and display values of

 

simulation results

get

Access and display values of

 

simulation results

who

Access and display output

 

variable names of simulation

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

Simulate the vdp model and place the results of the

Simulink.SimulationOutput object in simOut.

simOut = sim('vdp','SimulationMode','rapid','AbsTol','1e-5',...

'SaveState','on','StateSaveName','xoutNew',...

'SaveOutput','on','OutputSaveName','youtNew');

Store the variable names of the outputs in simOutVars, using the who method.

simOutVars = simOut.who

Simulink returns and displays:

simOutVars =

7-274

Simulink.SimulationOutput

 

 

'xoutNew'

 

 

'youtNew'

 

Get the values of the variable youtNew.

 

yout = simOut.get('youtNew')

 

Simulink returns and displays the values.

See Also

Simulink.SimulationData.BlockPath |

 

Simulink.SimulationData.Dataset

How To

“Specify the Signal Logging Data Format”

 

“Export Simulation Data”

7-275

Simulink.SoftwareTarget.AperiodicTrigger

 

Superclasses

Trigger

 

 

 

Purpose

Describe aperiodic trigger

 

Description

The Simulink.SoftwareTarget.AperiodicTrigger class describes an

 

 

aperiodic trigger object. This object inherits its properties and methods

 

 

from the Simulink.SoftwareTarget.Trigger class.

 

Properties

TargetObject

 

 

 

 

Target specific custom properties for the selected

 

 

EventHandlerType (see the table in EventHandlerType).

 

 

Data Type: Object

 

 

Access: Read only

 

 

EventHandlerType

 

 

 

 

Describes the aperiodic trigger source for the trigger. Valid

 

 

values depend on the value of the system target file for the active

 

 

configuration set:

 

 

 

 

 

 

System Target

EventHandlerType

TargetObject Class

 

 

File

 

 

 

 

ert.tlc,

Event (Windows)

Simulink.SoftwareTarget.WindowsEventHandler

 

 

grt.tlc,

 

 

 

 

idelink_ert.tlc,

 

 

 

 

idelink_grt.tlc

 

 

 

 

Ert.tlc,

POSIX® signal

Simulink.SoftwareTarget.PosixSignalHandler

 

 

grt.tlc,

(Linux®/VxWorks®

 

 

 

idelink_ert.tlc,

6.x)

 

 

 

idelink_grt.tlc

 

 

 

 

xpctarget.tlc,

xPC interrupt

xpcHardwareInterrupt

 

 

xpctargetert.tlc

 

 

 

 

 

 

 

 

7-276

Simulink.SoftwareTarget.AperiodicTrigger

Copy

Semantics

Examples

Alternatives

See Also

How To

Handle. To learn how handle classes affect copy operations, see Copying Objects in the MATLAB Programming Fundamentals documentation.

Add an aperiodic trigger to the sldemo_concurrent_execution model.

%Load example model sldemo_concurrent_execution

%Access its configuration set

configSet = getActiveConfigSet('sldemo_concurrent_execution'); % Access task configuration data

taskConfig = configSet.concurrentExecutionComponents; % Add an aperiodic trigger

myTrigger = taskConfig.addAperiodicTrigger('MyTrigger') % Set the name of the newly added aperiodic trigger myTrigger.Name = 'MyTrigger';

“Customize Concurrent Execution Settings”

Simulink.SoftwareTarget.Trigger |

Simulink.SoftwareTarget.PeriodicTrigger

• “Customize Concurrent Execution Settings”

7-277

Simulink.SoftwareTarget.PeriodicTrigger

Superclasses

Purpose

Description

Copy

Semantics

Examples

Alternatives

See Also

How To

Trigger

Describe periodic trigger

The Simulink.SoftwareTarget.PeriodicTrigger class describes a periodic trigger object. This object inherits its properties and methods

from the Simulink.SoftwareTarget.Trigger class.

Handle. To learn how handle classes affect copy operations, see Copying Objects in the MATLAB Programming Fundamentals documentation.

Add an aperiodic trigger for the sldemo_concurrent_execution model.

%Load example model sldemo_concurrent_execution

%Access its configuration set

configSet = getActiveConfigSet('sldemo_concurrent_execution'); % Access task configuration data

taskConfig = configSet.concurrentExecutionComponents; % Access and change the name of the periodic trigger taskConfig.Triggers(1).Name = 'MyTrigger';

“Customize Concurrent Execution Settings”

Simulink.SoftwareTarget.Trigger |

Simulink.SoftwareTarget.AperiodicTrigger

• “Customize Concurrent Execution Settings”

7-278

Simulink.SoftwareTarget.PosixSignalHandler

Superclasses

Purpose

Description

Construction

Properties

Copy

Semantics

Examples

Describe aperiodic trigger for POSIX targets

The Simulink.SoftwareTarget.PosixSignalHandler class describes an aperiodic trigger for one or more POSIX signals.

Create a Simulink.SoftwareTarget.PosixSignalHandler object by setting the EventHandlerType type of an aperiodic trigger object to

Posix Signal (Linux/VxWorks 6.x). This object is created as a side effect and stored in the TargetObject property of the aperiodic trigger object.

SignalNumber

Signal number in the range from 2 to SIGRTMAX-SIGRTMIN-1, where SIGRTMAX is the maximum value and SIGRTMIN is the minimum value of the signals supported by the target Linux or VxWorks operating system.

Data Type: Integer Access: Read write

Handle. To learn how handle classes affect copy operations, see Copying Objects in the MATLAB Programming Fundamentals documentation.

Create a Simulink.SoftwareTarget.PosixSignalHandler object.

% Open demo model sldemo_concurrent_execution % Access configuration set

configSet = getActiveConfigSet('sldemo_concurrent_execution'); % Access concurrent execution

taskConfig = configSet.concurrentExecutionComponents; % Add an aperiodic trigger

trigger = taskConfig.addAperiodicTrigger('MyTrigger'); % Specify custom target

7-279

Simulink.SoftwareTarget.PosixSignalHandler

Alternatives

See Also

How To

trigger.EventHandlerType = 'Posix Signal (Linux/VxWorks 6.x)'; % Access the custom target data

trigger.TargetObject

“Customize Concurrent Execution Settings”

Simulink.SoftwareTarget.TaskConfiguration |

Simulink.SoftwareTarget.WindowsEventHandler |

Simulink.SoftwareTarget.Trigger.addTask

• “Customize Concurrent Execution Settings”

7-280

Simulink.SoftwareTarget.TaskConfiguration

Purpose

Configure model for concurrent execution

Description

The Simulink.SoftwareTarget.TaskConfiguration object contains

 

the task configuration information for the concurrent execution of a

 

model.

Construction

Create Simulink.SoftwareTarget.TaskConfiguration object by

 

configuring a model for concurrent execution.

Properties

Name

Name of Simulink.SoftwareTarget.TaskConfiguration object.

Data Type: String

Access: Read/write

Triggers

Vector of periodic and aperiodic triggers, each of which describes trigger conditions for a set of tasks.

Data Type: Vector Access: Read only

TargetCustomizationObject

Set of valid triggers for a deployment target.

Data Type: Object. For example,

Simulink.SoftwareTarget.GRTCustomization.

Access: Read only

BlockToTaskMapping

Specification of block to task mapping.

Data Type: Object

Access: Read only

7-281

Simulink.SoftwareTarget.TaskConfiguration

Methods

Copy

Semantics

Examples

addAperiodicTrigger

Add aperiodic trigger to task

 

configuration

deleteTrigger

Delete aperiodic trigger from task

 

configuration

findTrigger

Return trigger object

map

Map block to object

unmap

Remove mapping from block to

 

specified object

Handle. To learn how handle classes affect copy operations, see Copying Objects in the MATLAB Programming Fundamentals documentation.

Create a Simulink.SoftwareTarget.TaskConfiguration object.

Alternatives

See Also

How To

%Create a new model new_system('MyModel');

%Open the new model open_system('MyModel');

configSet = Simulink.SoftwareTarget.concurrentExecution('MyModel',...

'AddConfigurationForConcurrentExecution'); % Access the task configuration object

taskConfig = configSet.concurrentExecutionComponents;

“Customize Concurrent Execution Settings”

Simulink.SoftwareTarget.TaskConfiguration.addAperiodicTrigger

| Simulink.SoftwareTarget.TaskConfiguration.deleteTrigger |

Simulink.SoftwareTarget.TaskConfiguration.map |

Simulink.SoftwareTarget.TaskConfiguration.unmap

• “Customize Concurrent Execution Settings”

7-282

Simulink.SoftwareTarget.Task

Superclasses

Purpose

Description

Properties

Copy

Semantics

Examples

Describe task that models unit of concurrent execution

The Simulink.SoftwareTarget.Task class describes a task that models a unit of concurrent execution.

Color

Color of the task icon.

Data Type: Vector of three doubles for an RGB triplet ([R,G,B]) Access: Read only

Name

Task name.

Data Type: string

Access: Read/write

Period

Period of task. This value must be a positive real number or a positive ratio.

Data Type: real Access: Read/write

Handle. To learn how handle classes affect copy operations, see Copying Objects in the MATLAB Programming Fundamentals documentation.

Create a Simulink.SoftwareTarget.Task object for the sldemo_concurrent_execution model.

%Load example model sldemo_concurrent_execution

%Access its configuration set

configSet = getActiveConfigSet('sldemo_concurrent_execution'); % Access task configuration data

7-283

Simulink.SoftwareTarget.Task

Alternatives

See Also

How To

taskConfig = configSet.concurrentExecutionComponents; % Add a new task object

taskObject = taskConfig.Triggers(1).addTask('MyTask');

%Set the color of the task object taskObject.Color = [1 0 0];

%Delete the task object taskConfig.Triggers.deleteTask(taskObject);

“Customize Concurrent Execution Settings”

Simulink.SoftwareTarget.TaskConfiguration

• “Customize Concurrent Execution Settings”

7-284

Simulink.SoftwareTarget.Trigger

Purpose

Base class for PeriodicTrigger and AperiodicTrigger

Description

Simulink.SoftwareTarget.Trigger is the base class for

 

the Simulink.SoftwareTarget.PeriodicTrigger and

 

Simulink.SoftwareTarget.AperiodicTrigger objects.

Construction

This is an abstract class. See

 

Simulink.SoftwareTarget.AperiodicTrigger and

 

Simulink.SoftwareTarget.PeriodicTrigger for concrete classes.

Properties

Name

 

Name of trigger.

 

Data Type: String

 

Access: Read/write

 

TriggerType

 

Type of trigger.

 

Data Type: Enumeration. Can be one of:

 

'Periodic'

 

'Aperiodic'

 

Access: Read only

 

Tasks

 

Vector of tasks defined for this trigger.

 

Data Type: Vector

 

Access: Read only

 

Color

 

Color for rendering the trigger.

 

Data Type: RGB vector of doubles ([R,G,B])

7-285

Simulink.SoftwareTarget.Trigger

Access: Read/write

Methods

addTask

Add task to specified trigger

deleteTask

Delete specified task from trigger

findTask

Return task object

Copy

Semantics

Alternatives

See Also

How To

Handle. To learn how handle classes affect copy operations, see Copying Objects in the MATLAB Programming Fundamentals documentation.

“Customize Concurrent Execution Settings”

Simulink.SoftwareTarget.Trigger.addTask |

Simulink.SoftwareTarget.AperiodicTrigger |

Simulink.SoftwareTarget.PeriodicTrigger |

Simulink.SoftwareTarget.Trigger.deleteTask |

Simulink.SoftwareTarget.Trigger.findTask

• “Customize Concurrent Execution Settings”

7-286

Simulink.SoftwareTarget.WindowsEventHandler

Superclasses

Purpose

Description

Construction

Properties

Copy

Semantics

Examples

Describe aperiodic trigger for Windows targets

The Simulink.SoftwareTarget.WindowsEventHandler class describes an aperiodic trigger for one or more signals on Windows targets.

Create a Simulink.SoftwareTarget.WindowsEventHandler object by setting the EventHandlerType type of an aperiodic trigger object to Event (Windows). This object is created as a side effect and stored in the TargetObject property of the aperiodic trigger object.

EventName

Name associated with the aperiodic trigger. Specify a valid Windows path name component, excluding backslash (`\'), limited to MAX_PATH characters.

Data Type: String

Access: Read/write

Handle. To learn how handle classes affect copy operations, see Copying Objects in the MATLAB Programming Fundamentals documentation.

Create a Simulink.SoftwareTarget.WindowsEventHandler object.

% Open demo model sldemo_concurrent_execution % Access configuration set

configSet = getActiveConfigSet('sldemo_concurrent_execution'); % Access concurrent execution

taskConfig = configSet.concurrentExecutionComponents; % Add an aperiodic trigger

trigger = taskConfig.addAperiodicTrigger('MyTrigger'); trigger.EventHandlerType = 'Event (Windows)';

%Specify custom target

%Access the custom target data

7-287

Simulink.SoftwareTarget.WindowsEventHandler

trigger.TargetObject

See Also Simulink.SoftwareTarget.TaskConfiguration |

Simulink.SoftwareTarget.PosixSignalHandler |

Simulink.SoftwareTarget.Trigger.addTask

7-288

Simulink.SoftwareTarget.TaskConfiguration.addAperiodic

Purpose

Syntax

Description

Input

Arguments

Output

Arguments

Examples

Alternatives

See Also

Add aperiodic trigger to task configuration

aperiodic_trigger = addAperiodicTrigger(trigger_name)

aperiodic_trigger = addAperiodicTrigger(trigger_name) adds the aperiodic trigger, aperiodic_trigger, to the task configuration.

trigger_name

Name of trigger object.

Default: none

aperiodic_trigger

Aperiodic trigger object. If trigger_name is the name of another trigger object within the parent task configuration, the software makes trigger_name unique by appending the smallest integer, for example, aperiodic_trigger1.

Add an aperiodic trigger to the sldemo_concurrent_execution model.

%Load example model sldemo_concurrent_execution

%Access its configuration set

configSet = getActiveConfigSet('sldemo_concurrent_execution'); % Access task configuration data

taskConfig = configSet.concurrentExecutionComponents; % Add an aperiodic trigger

myTrigger = taskConfig.addAperiodicTrigger('MyTrigger') % Set the name of the newly added aperiodic trigger myTrigger.Name = 'MyTrigger';

“Customize Concurrent Execution Settings”

Simulink.SoftwareTarget.TaskConfiguration |

Simulink.SoftwareTarget.TaskConfiguration.deleteTrigger

7-289

Simulink.SoftwareTarget.TaskConfiguration.addAperiodicTrigg

| Simulink.SoftwareTarget.TaskConfiguration.map |

Simulink.SoftwareTarget.TaskConfiguration.unmap

How To

• “Customize Concurrent Execution Settings”

7-290

Simulink.SoftwareTarget.TaskConfiguration.deleteTrigger

Purpose

Delete aperiodic trigger from task configuration

Syntax

deleteTrigger(trigger_name)

 

deleteTrigger(trigger_number)

Description

deleteTrigger(trigger_name) deletes the specified aperiodic

 

trigger, trigger_name, from the task configuration. This method

 

returns an error if trigger_name is the first periodic trigger in the

 

task configuration, or if trigger_name does not exist in the task

 

configuration.

 

deleteTrigger(trigger_number) deletes the specified aperiodic

 

trigger, trigger_number, from the task configuration. This method

 

returns an error if trigger_number is the first periodic trigger in

 

the task configuration, or if trigger_number does not exist in the

 

task configuration.

Input

trigger_name

Arguments

Name of trigger object.

 

 

Default: none

 

trigger_number

 

Index number of trigger object.

Examples

Delete trigger by trigger number.

 

triggers = taskConfiguration.Triggers

 

for i=2:length(triggers)

 

taskConfiguration.deleteTrigger(triggers(i))

 

end

7-291

Simulink.SoftwareTarget.TaskConfiguration.deleteTrigger

See Also Simulink.SoftwareTarget.TaskConfiguration |

Simulink.SoftwareTarget.TaskConfiguration.addAperiodicTrigger

| Simulink.SoftwareTarget.TaskConfiguration.map |

Simulink.SoftwareTarget.TaskConfiguration.unmap

7-292

Simulink.SoftwareTarget.TaskConfiguration.findTrigger

Purpose

Syntax

Description

Input

Arguments

Output

Arguments

See Also

Return trigger object

aperiodic_trigger = findTrigger(trigger_name)

aperiodic_trigger = findTrigger(trigger_name) returns the specified trigger object.

trigger_name

Name of trigger object.

Default: none

aperiodic_trigger

Aperiodic trigger object.

Simulink.SoftwareTarget.TaskConfiguration |

Simulink.SoftwareTarget.TaskConfiguration.deleteTrigger

| Simulink.SoftwareTarget.TaskConfiguration.map |

Simulink.SoftwareTarget.TaskConfiguration.unmap

7-293

Simulink.SoftwareTarget.TaskConfiguration.map

Purpose

Syntax

Description

Input

Arguments

Map block to object

map(block_handle,task_object) map(block_handle,aperiodic_object) map(block_handle,trigger_number, task_name) map(block_handle,trigger_name, task_name) map(block_handle,trigger_name) map(block_handle,trigger_number)

map(block_handle,task_object) maps the given block to the task object.

map(block_handle,aperiodic_object) maps the given block to the aperiodic trigger object.

map(block_handle,trigger_number, task_name) maps the given block to the task object, as identified by the trigger number and task name.

map(block_handle,trigger_name, task_name) maps the given block to the task object, as identified by the trigger name and task name.

map(block_handle,trigger_name) maps the given block to the aperiodic trigger object, as identify by the trigger name, in the task configuration.

map(block_handle,trigger_number) maps the given block to the aperiodic trigger object, as identified by the trigger number, in the task configuration.

block_handle

Handle (double) of block to map.

task_object

Task object to map to block_handle.

aperiodic_object

Aperiodic task object to map to block_handle.

7-294

Simulink.SoftwareTarget.TaskConfiguration.map

Examples

Alternatives

See Also

trigger_number

Identifier of trigger object.

task_name

Name of task to associate with the trigger to identify the task object.

trigger_name

Name of trigger object.

Default: none

Create a new task and map a block to the new task.

% Open demo model sldemo_concurrent_execution % Get the configuration set

configSet = getActiveConfigSet('sldemo_concurrent_execution'); taskConfig = configSet.concurrentExecutionComponents;

% Get the block of interest

block = get_param('sldemo_concurrent_execution/Plant', 'Handle'); % Create a new task

newTask = taskConfig.Triggers(1).addTask('NewTask'); newTask.Period = '0.1';

%Get the task to which plant was mapped to

oldTask = taskConfig.Triggers(1).findTask('Plant');

%Map the plant block to the new task taskConfig.unmap(block, oldTask); taskConfig.map(block, newTask);

“Customize Concurrent Execution Settings”

Simulink.SoftwareTarget.TaskConfiguration |

Simulink.SoftwareTarget.TaskConfiguration.addAperiodicTriger

| Simulink.SoftwareTarget.TaskConfiguration.deleteTrigger |

Simulink.SoftwareTarget.TaskConfiguration.unmap

7-295

Simulink.SoftwareTarget.TaskConfiguration.map

How To

• “Customize Concurrent Execution Settings”

7-296

Simulink.SoftwareTarget.TaskConfiguration.unmap

Purpose

Syntax

Description

Input

Arguments

Remove mapping from block to specified object

unmap(block_handle,task_object) unmap(block_handle,aperiodic_object) unmap(block_handle,trigger_number, task_name) unmap(block_handle,trigger_name, task_name) unmap(block_handle,trigger_name) unmap(block_handle,trigger_number)

unmap(block_handle,task_object) removes the mapping from the given block to the task object.

unmap(block_handle,aperiodic_object) removes the mapping from the given block to the aperiodic trigger object.

unmap(block_handle,trigger_number, task_name) removes the mapping from the given block to the task object, as identified by the trigger number and task name.

unmap(block_handle,trigger_name, task_name) removes the mapping from the given block to the task object, as identified by the trigger name and task name.

unmap(block_handle,trigger_name) removes the mapping from the given block to the aperiodic trigger object, as identified by the trigger name, in the task configuration.

unmap(block_handle,trigger_number) removes the mapping from the given block to the aperiodic trigger object, as identified by the trigger number, in the task configuration.

block_handle

Handle (double) of block from which to remove mapping.

task_object

Task object from which to remove mapping.

aperiodic_object

7-297

Simulink.SoftwareTarget.TaskConfiguration.unmap

Examples

See Also

Aperiodic task object from which to remove mapping.

trigger_number

Identifier of trigger object.

task_name

Name of task to associate with the trigger to identify the task object.

trigger_name

Name of trigger object.

Default: none

Create a new task, map a block to the new task, and then unmap the block.

% Open demo model sldemo_concurrent_execution % Get the configuration set

configSet = getActiveConfigSet('sldemo_concurrent_execution'); taskConfig = configSet.concurrentExecutionComponents;

% Get the block of interest

block = get_param('sldemo_concurrent_execution/Plant', 'Handle'); % Create a new task

newTask = taskConfig.Triggers(1).addTask('NewTask'); newTask.Period = '0.1';

%Get the task to which plant was mapped to

oldTask = taskConfig.Triggers(1).findTask('Plant');

%Map the plant block to the new task taskConfig.unmap(block, oldTask); taskConfig.map(block, newTask);

Simulink.SoftwareTarget.TaskConfiguration |

Simulink.SoftwareTarget.TaskConfiguration.addAperiodicTrigger

| Simulink.SoftwareTarget.TaskConfiguration.deleteTrigger |

Simulink.SoftwareTarget.TaskConfiguration.map

7-298

Simulink.SoftwareTarget.Trigger.addTask

Purpose

Syntax

Description

Input

Arguments

Output

Arguments

Examples

Alternatives

Add task to specified trigger

addTask(task_name)

addTask(task_name) adds a task to the trigger. If task_name already exists, the method renames the task to the next available incremental name, such as task_name1.

task_name

Name of task to associate with the trigger to identify the task object.

task_object

Task object, with name task_name, associated with the trigger.

Create a new task.

% Open demo model sldemo_concurrent_execution % Get the configuration set

configSet = getActiveConfigSet('sldemo_concurrent_execution'); taskConfig = configSet.concurrentExecutionComponents;

% Get the block of interest

block = get_param('sldemo_concurrent_execution/Plant', 'Handle'); % Create a new task

newTask = taskConfig.Triggers(1).addTask('NewTask'); newTask.Period = '0.1';

%Get the task to which plant was mapped to

oldTask = taskConfig.Triggers(1).findTask('Plant');

%Map the plant block to the new task taskConfig.unmap(block, oldTask); taskConfig.map(block, newTask);

“Customize Concurrent Execution Settings”

7-299

Simulink.SoftwareTarget.Trigger.addTask

See Also

Simulink.SoftwareTarget.Trigger |

 

Simulink.SoftwareTarget.Trigger.deleteTask |

 

Simulink.SoftwareTarget.Trigger.findTask

How To

• “Customize Concurrent Execution Settings”

7-300

Simulink.SoftwareTarget.Trigger.deleteTask

Purpose

Syntax

Description

Input

Arguments

Examples

See Also

Delete specified task from trigger

deleteTask(task_name) deleteTask(task_object)

deleteTask(task_name) deletes a task, task_name, from the trigger. The method returns an error if the task does not exist in the trigger.

deleteTask(task_object) deletes a task object from the trigger.

task_name

Name of task to associate with the trigger to identify the task object.

task_object

Task object to remove from the trigger.

Create a new task and then delete the task.

%Load example model sldemo_concurrent_execution

%Access its configuration set

configSet = getActiveConfigSet('sldemo_concurrent_execution'); % Access task configuration data

taskConfig = configSet.concurrentExecutionComponents; % Add a new task object

taskObject = taskConfig.Triggers(1).addTask('MyTask');

%Set the color of the task object taskObject.Color = [1 0 0];

%Delete the task object taskConfig.Triggers(1).deleteTask(taskObject);

Simulink.SoftwareTarget.Trigger |

Simulink.SoftwareTarget.Trigger.addTask |

Simulink.SoftwareTarget.Trigger.findTask

7-301

Simulink.SoftwareTarget.Trigger.findTask

Purpose

Syntax

Description

Input

Arguments

Output

Arguments

Examples

Return task object

task_object = findTask(task_name)

task_object = findTask(task_name) returns the specified task object. The method returns an error if it does not find a task with the specified name.

task_name

Name of task to associate with the trigger to identify the task object.

task_object

Task object found.

Create a new task and find the old task.

% Open demo model sldemo_concurrent_execution % Get the configuration set

configSet = getActiveConfigSet('sldemo_concurrent_execution'); taskConfig = configSet.concurrentExecutionComponents;

% Get the block of interest

block = get_param('sldemo_concurrent_execution/Plant', 'Handle'); % Create a new task

newTask = taskConfig.Triggers(1).addTask('NewTask'); newTask.Period = '0.1';

%Get the task to which plant was mapped to

oldTask = taskConfig.Triggers(1).findTask('Plant');

%Map the plant block to the new task taskConfig.unmap(block, oldTask); taskConfig.map(block, newTask);

%Delete task

taskConfig.Triggers(1).deleteTask('NewTask')

7-302

Simulink.SoftwareTarget.Trigger.findTask

See Also Simulink.SoftwareTarget.Trigger |

Simulink.SoftwareTarget.Trigger.addTask |

Simulink.SoftwareTarget.Trigger.deleteTask

7-303

Simulink.SubsysDataLogs

Purpose

Container for subsystem’s signal data logs

Description

Note The Simulink.SubsysDataLogs class is used in conjunction with the ModelDataLogs logging data format. The ModelDataLogs format is supported for backwards compatibility. The ModelDataLogs format will be removed in a future release.

For new models, use the Dataset logging format.

Simulink software creates instances of this class to contain logs for signals belonging to a subsystem (see “Export Signal Data Using Signal Logging”). Objects of this class have a variable number of properties. The first property, named Name, is the name of the subsystem whose log data this object contains. The remaining properties are signal

log or signal log container objects containing the data logged for the subsystem specified by this object’s Name property.

Consider, for example, the following model.

After simulation of this model, the MATLAB workspace contains a

Simulink.ModelDataLogs object, named logsout, that contains a

7-304

Simulink.SubsysDataLogs

Simulink.SubsysDataLogs object, named Gain, that contains the log data for signals a and m in the subsystem named Gain.

>> logsout.Gain

 

 

ans =

 

 

Simulink.SubsysDataLogs (Gain):

 

Name

elements

Simulink Class

a

1

Timeseries

m

2

TsArray

You can use either fully qualified log names or the unpack command to access the signal logs contained by a SubsysDataLogs object. For example, to access the amplitudes logged for signal a in the preceding example, you could enter the following at the MATLAB command line:

>> data = logsout.Gain.a.Data;

or

>> logsout.unpack('all'); data = a.Data;

See Also “Signal Logging”, Simulink.ModelDataLogs, Simulink.ScopeDataLogs, Simulink.Timeseries, Simulink.TsArray, Simulink.SimulationData.Dataset, who, whos, unpack

7-305

Simulink.TimeInfo

Purpose

Description

Properties

Provide information about time data in Simulink.Timeseries object

Simulink software creates instances of these objects to describe the time data that it includes in Simulink.Timeseries objects.

 

Name

Access

Description

 

 

Units

RW

The units, e.g., 'seconds', in which the

 

 

 

 

time series data are expressed in the

 

 

 

 

associated Simulink.Timeseries object.

 

 

Start

RW

If the associated signal is not in a

 

 

 

 

conditionally executed subsystem, this

 

 

 

 

field contains the simulation time of

 

 

 

 

the first signal value recorded in the

 

 

 

 

associated Simulink.Timeseries object.

 

 

 

 

If the signal is in a conditionally executed

 

 

 

 

subsystem, this field contains an array of

 

 

 

 

times when the system became active.

 

 

end

RW

If the associated signal is not in a

 

 

 

 

conditionally executed subsystem, this

 

 

 

 

field contains the simulation time of the

 

 

 

 

last signal value recorded in the associated

 

 

 

 

Simulink.Timeseries object. If the signal

 

 

 

 

is in a conditionally executed subsystem,

 

 

 

 

this field contains an array of times when

 

 

 

 

the system became inactive.

 

7-306

Simulink.TimeInfo

 

Name

Access

Description

 

 

Increment

RW

The interval between simulation times

 

 

 

 

at which signal data is logged in the

 

 

 

 

associated Simulink.Timeseries object.

 

 

 

 

If the signal is aperiodic (continuous signal

 

 

 

 

with variable-step solver), this property

 

 

 

 

has a value of NaN. A signal is periodic if it

 

 

 

 

has a discrete sample time (not continuous

 

 

 

 

or constant) or is continuous with a

 

 

 

 

fixed-step solver.

 

 

Length

W

The number of signal samples recorded

 

 

 

 

in the associated Simulink.Timeseries

 

 

 

 

object, i.e., the length of the arrays

 

 

 

 

referenced by the object’s Time and Data

 

 

 

 

properties.

 

See Also Simulink.Timeseries , Simulink.SimulationData.Dataset

7-307

Simulink.Timeseries

Purpose

Description

Properties

See Also

Store data for any signal except mux or bus signal

Simulink software creates instances of this class to store signal data that it logs for any signal except a mux or bus signal, which are stored in a Simulink.TsArray. See “Export Signal Data Using Signal Logging” for more information.

 

Name

Access

Description

 

 

Name

RW

Name of this signal log.

 

 

BlockPath

RW

Path of the block that output the signal

 

 

 

 

logged in this signal log.

 

 

PortIndex

RW

Index of the output port that emitted the

 

 

 

 

signal logged in this signal log.

 

 

SignalName

RW

Name of the signal logged in this signal

 

 

 

 

log.

 

 

ParentName

RW

Name of the parent of the signal recorded

 

 

 

 

in this log, if the signal is an element of a

 

 

 

 

mux or a virtual bus; otherwise, the same

 

 

 

 

as SignalName.

 

 

TimeInfo

RW

An object of Simulink.TimeInfo class

 

 

 

 

that describes the time data in this log.

 

 

Time

RW

An array containing the simulation times

 

 

 

 

at which signal data was logged.

 

 

Data

RW

An array containing the signal data.

 

 

 

 

 

 

“Export Signal Data Using Signal Logging”, Simulink.TimeInfo,

Simulink.SimulationData.Dataset, Simulink.ModelDataLogs, Simulink.SubsysDataLogs, Simulink.ScopeDataLogs, Simulink.TsArray, who, whos, unpack

7-308

Simulink.TsArray

Purpose

Store data for mux or bus signal

Description Simulink software creates instances of this class to contain the data that it logs for a mux or bus signal. Other types of signals are stored in a Simulink.Timeseries. See “Export Signal Data Using Signal Logging” for more information.

Objects of the Simulink.TsArray class have a variable number of properties. The first property, called Name, specifies the log name of the logged signal. The remaining properties reference logs for the elements of the logged signal: Simulink.Timeseries objects for elementary signals and Simulink.TSArray objects for mux or bus signals. The name of each property is the log name of the corresponding signal.

For example, consider the following model.

This model specifies that Simulink software should log the values of the signal b2 during simulation. After simulation of this model, the MATLAB workspace contains a Simulink.ModelDataLogs object, named logsout, that contains a Simulink.TsArray object, named b2, that contains the logs for the elements of b2, i.e., for the elementary signal x1 and the bus signal b1. entering the fully qualified name of the Simulink.TsArray object, i.e., logsout.b2, at the MATLAB command line reveals the structure of the signal log for this model.

7-309

Simulink.TsArray

>> logsout.b2

 

 

Simulink.TsArray (untitled/Bus Creator1):

Name

elements

Simulink Class

x1

1

Timeseries

b1

2

TsArray

 

You can use either fully qualified log names or the unpack command

 

to access the signal logs contained by a Simulink.TsArray object. For

 

example, to access the amplitudes logged for signal x1 in the preceding

 

example, you could enter the following at the MATLAB command line:

 

>> data = logsout.b2.x1.Data;

 

or

 

>> logsout.unpack('all');

 

data = x1.Data;

See Also

“Export Signal Data Using Signal Logging”,Simulink.ModelDataLogs,

 

Simulink.SubsysDataLogs, Simulink.ScopeDataLogs,

 

Simulink.Timeseries, Simulink.SimulationData.Dataset, who,

 

whos, unpack

7-310

Simulink.Variant

Purpose

Specify a model reference variant and its execution environment

Description

A Simulink.Variant object specifies a variant object, which is defined

 

using a Boolean expression called a variant condition. A Model Variants

 

block and a Variant Subsystem block use variant objects to associate an

 

execution environment with each of its variants.

 

The variant condition references MATLAB variables and/or Simulink

 

parameter objects in the base workspace called variant control

 

variables. The variant condition must evaluate to true or false when

 

the model is compiled.

 

For a given Model Variants block or Variant Subsystem block, you

 

must define the variant objects so that only one evaluates to true. The

 

variant object, whose variant condition evaluates to true, is the active

 

variant for that variant block.

Construction

variant=Simulink.Variant(VariantCondition) creates a variant

 

object in the base workspace. The object name is variant, and the

 

associated variant condition is VariantCondition. The object can have

 

any unique legal MATLAB name.

 

The VariantCondition must be a Boolean expression that references at

 

least one base workspace variable or parameter. A variant condition

 

can include scalar variables, enumerated values, the operators ==,

 

!=, &&, ||, ~, as well as parentheses for grouping. If you specify the

 

condition literally, surround it with single quotes.

 

You can also create a variant object using the Model explorer. Select

 

the Base Workspace, choose Add > Simulink.Variant, and specify

 

the desired name and variant condition in the Contents and Dialog

 

panes. If you specify the condition literally, do not surround it with

 

single quotes (unlike the MATLAB API, which requires single quotes).

Properties

 

 

Condition

 

Description

 

The Boolean expression associated with the variant object.

7-311

Simulink.Variant

Examples

See Also

Access

RW

Create a variant object with a variant condition:

GU=Simulink.Variant('Fuel==1 && Emis==1')

“About Variant Objects”

“Variant Systems”

7-312

Simulink.WorkspaceVar

Purpose

Description

Tip

Fields

Contains information about workspace variables and blocks that use them

Note Simulink.WorkspaceVar will be removed in a future release. Use Simulink.VariableUsage instead.

A Simulink.WorkspaceVar object describes attributes of a workspace variable and lists the blocks that use the variable. The Simulink.findVars function returns one or more

Simulink.WorkspaceVar objects that embody the results of searching for variables.

Only a Simulink.WorkspaceVar constructor can set any field value in a Simulink.WorkspaceVar object. The fields are otherwise read-only.

Name

The name of the variable described by the

Simulink.WorkspaceVar object

Workspace

The name of the workspace in which the variable resides, for example:

 

 

Workspace value

Meaning

 

 

 

'base

The MATLAB base workspace

 

 

 

workspace'

 

 

 

 

'MyModel'

The model workspace for the model

 

 

 

 

MyModel.

 

 

 

'MyModel/Mask1'

The mask workspace for the masked block

 

 

 

 

Mask1 in the model MyModel.

 

WorkspaceType

 

 

7-313

Simulink.WorkspaceVar

Construction

Methods

Examples

The type of workspace in which the variable resides. The possible values are:

'base'

'model'

'mask'

UsedByBlocks

A cell array of strings. Each string names a block that uses the variable. Simulink.findVars populates this field.

var = Simulink.WorkspaceVar (VarName, WkspName), where both arguments are strings, returns a Simulink.WorkspaceVar object with Name VarName and Workspace WkspName. The inputs need not exist in the model. Simulink will provide a WorkspaceType automatically.

vars = Simulink.WorkspaceVar (VarNames, WkspName), where VarNames is a cell array of strings, returns a vector of Simulink.WorkspaceVar objects, each with a specified name and

Workspace = WkspName.

[VarsOut] = VarsIn1.setdiff (VarsIn2) — Calls setdiff to return the difference between VarsIn1 and VarsIn2. The arguments and return value are vectors of Simulink.WorkspaceVar objects.

[VarsOut] = VarsIn1.intersect (VarsIn2) — Calls intersect to return the intersection between VarsIn1 and VarsIn2. The arguments and return value are vectors of Simulink.WorkspaceVar objects.

Create a Simulink.WorkspaceVar object for the variable 'k' in the base workspace.

var = Simulink.WorkspaceVar('k', 'base workspace');

Return a vector of Simulink.WorkspaceVar objects, one object for each variable returned by who.

7-314

Simulink.WorkspaceVar

[vars] = Simulink.WorkspaceVar (who, WkspName)

Return a vector of Simulink.WorkspaceVar objects, one object for each variable returned by whos.

[vars] = Simulink.WorkspaceVar (who, WkspName)

Create a vector of Simulink.WorkspaceVar objects that describes all the variables in a model workspace

hws = get_param('mymodel', 'ModelWorkspace'); vars=Simulink.WorkspaceVar(hws.whos, 'MyModel')

Create a vector of Simulink.WorkspaceVar objects that describes all the variables in a mask workspace

maskVars = get_param('mymodel/maskblock', 'MaskWSVariables'); vars = Simulink.WorkspaceVar(maskVars, 'mymodel/maskblock');

See Also Simulink.findVars

setdiff

intersect

7-315

Simulink.VariableUsage

Purpose

Tip

Description

Construction

Properties

Get information about workspace variables and blocks that use them

Only a Simulink.VariableUsage constructor can set any field value in a Simulink.VariableUsage object. The fields are otherwise read-only.

Create a Simulink.VariableUsage object to get the attributes of a workspace variable and determine the blocks that use the variable.

Create a Simulink.VariableUsage object as follows.

var = Simulink.VariableUsage (VarName, WkspName), where both arguments are strings, returns a Simulink.VariableUsage object with Name VarName and Workspace WkspName. The inputs need not exist in the model. Simulink will provide a WorkspaceType automatically.

vars = Simulink.VariableUsage (VarNames, WkspName), where VarNames is a cell array of strings, returns a vector of Simulink.VariableUsage objects, each with a specified name and

Workspace = WkspName.

Name

The name of the variable described by the

Simulink.VariableUsage object

Workspace

The name of the workspace in which the variable resides, for example:

 

Workspace value

Meaning

 

 

'base

The MATLAB base workspace

 

 

workspace'

 

 

 

'MyModel'

The model workspace for the model

 

 

 

MyModel.

 

 

'MyModel/Mask1'

The mask workspace for the masked block

 

 

 

Mask1 in the model MyModel.

 

7-316

Simulink.VariableUsage

Methods

Examples

WorkspaceType

The type of workspace in which the variable resides. The possible values are:

'base workspace'

'model'

'mask'

UsedByBlocks

A cell array of strings. Each string names a block that uses the variable. Simulink.findVars populates this field.

[VarsOut] = VarsIn1.setdiff (VarsIn2) — Calls setdiff to return the difference between VarsIn1 and VarsIn2. The arguments and return value are vectors of Simulink.VariableUsage objects.

[VarsOut] = VarsIn1.intersect (VarsIn2) — Calls intersect to return the intersection between VarsIn1 and VarsIn2. The arguments and return value are vectors of Simulink.VariableUsage objects.

Create a Simulink.VariableUsage object for the variable 'k' in the base workspace.

var = Simulink.VariableUsage('k', 'base workspace');

Return a vector of Simulink.VariableUsage objects, one object for each variable returned by who.

[vars] = Simulink.VariableUsage (who, WkspName)

Return a vector of Simulink.VariableUsage objects, one object for each variable returned by whos.

[vars] = Simulink.VariableUsage (who, WkspName)

7-317

Simulink.VariableUsage

 

Create a vector of Simulink.VariableUsage objects that describes all

 

the variables in a model workspace

 

hws = get_param('mymodel', 'ModelWorkspace');

 

vars=Simulink.VariableUsage(hws.whos, 'MyModel')

 

 

 

 

Create a vector of Simulink.VariableUsage objects that describes all

 

the variables in a mask workspace

 

maskVars = get_param('mymodel/maskblock', 'MaskWSVariables');

 

vars = Simulink.VariableUsage(maskVars, 'mymodel/maskblock');

See Also

Simulink.findVars | setdiff | intersect

7-318

Simulink.ModelManagement.Project.CurrentProject.loadP

Purpose

Load an existing Simulink project and close any currently open project

Syntax

p = Simulink.ModelManagement.Project.CurrentProject()

 

p.loadProject(pathtoprojectfolder)

Description

p = Simulink.ModelManagement.Project.CurrentProject() creates

 

an instance of the CurrentProject class.

 

p.loadProject(pathtoprojectfolder) loads the Simulink project in

 

the pathtoprojectfolder specified.

 

Loading a project closes any currently open project. If the currently

 

open project is configured to run shutdown shortcuts, the shutdown

 

tasks run before loading the next project.

Input

pathtoprojectfolder

Argument

The complete path to the folder that contains the

 

.SimulinkProject folder.

Example

To load an existing Simulink project, use the following commands.

 

1 Create an instance of the CurrentProject class.

 

p = Simulink.ModelManagement.Project.CurrentProject();

 

2 Use the loadProject method specifying the path to your project

 

folder (that contains the .SimulinkProject folder), for example:

 

p.loadProject('C:\work\airframe');

See Also

Simulink.ModelManagement.Project.CurrentProject

7-319

Simulink.ModelManagement.Project.CurrentProject.isProjectLo

Purpose

Return true when a Simulink project is loaded and false when no

 

project is loaded

Syntax

p = Simulink.ModelManagement.Project.CurrentProject()

 

isLoaded = p.isProjectLoaded

Description

p = Simulink.ModelManagement.Project.CurrentProject() creates

 

an instance of the CurrentProject class.

 

isLoaded = p.isProjectLoaded returns 1 or 0 depending on whether

 

a Simulink project is loaded or not loaded, respectively.

Example

To determine if a Simulink project is loaded, use the following

 

commands.

 

1 Create an instance of the CurrentProject class.

 

p = Simulink.ModelManagement.Project.CurrentProject();

 

2 Use the isProjectLoaded method.

 

isLoaded = p.isProjectLoaded;

 

isLoaded = 0 indicates that no Simulink project is loaded

 

isLoaded = 1 indicates a Simulink project is loaded

See Also

Simulink.ModelManagement.Project.CurrentProject

7-320

Simulink.ModelManagement.Project.CurrentProject.getRo

Purpose

Get the name of the root folder for the currently open Simulink project

Syntax

Description

Example

See Also

Note getRootDirectory will be removed in a future release. Use getRootFolder instead.

p = Simulink.ModelManagement.Project.CurrentProject() p.getRootDirectory

p = Simulink.ModelManagement.Project.CurrentProject() creates an instance of the CurrentProject class.

p.getRootDirectory returns the name of the root folder for the currently open Simulink project.

This method is particularly useful when creating start up and shutdown scripts, or functions, for a project. Use this method to determine the project root folder so that sub-folders of the project can be added to the MATLAB path without using absolute paths.

To get the name of the root folder for the currently open Simulink project, use the following commands.

1Create an instance of the CurrentProject class.

p = Simulink.ModelManagement.Project.CurrentProject();

2Use the getRootDirectory method. p.getRootDirectory;

Simulink.ModelManagement.Project.CurrentProject

7-321

Simulink.ModelManagement.Project.CurrentProject.getRootFol

Purpose

Get the name of the root folder for the currently open Simulink project

Syntax

p = Simulink.ModelManagement.Project.CurrentProject()

 

p.getRootFolder

Description

p = Simulink.ModelManagement.Project.CurrentProject() creates

 

an instance of the CurrentProject class.

 

p.getRootFolder returns the name of the root folder for the currently

 

open Simulink project.

 

This method is particularly useful when creating start up and shutdown

 

scripts, or functions, for a project. Use this method to determine the

 

project root folder so that sub-folders of the project can be added to the

 

MATLAB path without using absolute paths.

Example

To get the name of the root folder for the currently open Simulink

 

project, use the following commands.

 

1 Create an instance of the CurrentProject class.

 

p = Simulink.ModelManagement.Project.CurrentProject();

 

2 Use the getRootFolder method.

 

p.getRootFolder;

See Also

Simulink.ModelManagement.Project.CurrentProject

7-322

Simulink.ModelManagement.Project.CurrentProject.getPro

Purpose

Get the name of the currently open Simulink project

Syntax

p = Simulink.ModelManagement.Project.CurrentProject()

 

name = p.getProjectName

Description

p = Simulink.ModelManagement.Project.CurrentProject() creates

 

an instance of the CurrentProject class.

 

name = p.getProjectName returns the name of the currently open

 

Simulink project.

Example

To get the name of the currently open Simulink project, use the

 

following commands.

 

1 Create an instance of the CurrentProject class.

 

p = Simulink.ModelManagement.Project.CurrentProject();

 

2 Use the getProjectName method.

 

name = p.getProjectName;

See Also

Simulink.ModelManagement.Project.CurrentProject

7-323

Simulink.ModelManagement.Project.CurrentProject.getLabels

Purpose

Get a list of labels in a category in the currently open Simulink project

Syntax

p = Simulink.ModelManagement.Project.CurrentProject()

 

labels = p.getLabels(category)

Description

p = Simulink.ModelManagement.Project.CurrentProject() creates

 

an instance of the CurrentProject class.

 

labels = p.getLabels(category) returns an array of label names in

 

a specified category in the currently open Simulink project.

Input

category

Argument

The name of a category in the currently open Simulink project.

 

Examples To get a list of labels in category Review in the currently open Simulink project, use the following commands.

1Create an instance of the CurrentProject class.

p = Simulink.ModelManagement.Project.CurrentProject();

2Use the getLabels method.

labels = p.getLabels('Review');

3To view the cell array containing the category names, use labels{:}

To display all the labels within the currently open Simulink project, run the following code.

p = Simulink.ModelManagement.Project.CurrentProject(); categories = p.getCategories;

for jj = 1:numel(categories) thisCategory = categories{jj}; disp([thisCategory ' : ']);

labels = p.getLabels(thisCategory);

7-324

Simulink.ModelManagement.Project.CurrentProject.getLa

for kk = 1:numel(labels) thisLabel = labels(kk); disp([' - ' thisLabel.Name]);

end

end

See Also Simulink.ModelManagement.Project.CurrentProject

7-325

Simulink.ModelManagement.Project.CurrentProject.getFilesInP

Purpose

Syntax

Description

Example

See Also

Get a list of files in the currently open Simulink project

p = Simulink.ModelManagement.Project.CurrentProject() projFiles = p.getFilesInProject

projFiles = p.getFilesInProject(includeFolders)

p = Simulink.ModelManagement.Project.CurrentProject() creates an instance of the CurrentProject class.

projFiles = p.getFilesInProject returns a cell array of strings containing the fully qualified filenames of all the files and the folders in the currently open Simulink project.

projFiles = p.getFilesInProject(includeFolders) specifies whether to include folders in the list of project files. includeFolders is an optional logical input specifying whether to include folders (true) or exclude folders (false). Default: true.

To get the names of files in the currently open Simulink project, use the following commands.

1Create an instance of the CurrentProject class.

p = Simulink.ModelManagement.Project.CurrentProject()

2Use the getFilesInProject method. projFiles = p.getFilesInProject;

3To view the cell array containing the file names, use projFiles{:}

4Use the getFilesInProject method and exclude folders. projFiles = p.getFilesInProject(false);

Simulink.ModelManagement.Project.CurrentProject

7-326

Simulink.ModelManagement.Project.CurrentProject.getCa

Purpose

Get a list of the categories of file labels in the currently open Simulink

 

project

Syntax

p = Simulink.ModelManagement.Project.CurrentProject()

 

categories = p.getCategories

Description

p = Simulink.ModelManagement.Project.CurrentProject() creates

 

an instance of the CurrentProject class.

 

categories = p.getCategories returns a cell array of category names

 

in the currently open Simulink project.

Example

To get a list of categories in the currently open Simulink project, use

 

the following commands.

 

1 Create an instance of the CurrentProject class.

 

p = Simulink.ModelManagement.Project.CurrentProject();

 

2 Use the getCategories method.

 

categories = p.getCategories;

 

3 To view the cell array containing the category names, use

 

categories{:}

See Also

Simulink.ModelManagement.Project.CurrentProject

7-327

Simulink.ModelManagement.Project.CurrentProject.getAttache

Purpose

Get a list of labels attached to a file in the currently open Simulink

 

project

Syntax

p = Simulink.ModelManagement.Project.CurrentProject()

 

labels = p.getAttachedLabels(filePath)

Description

p = Simulink.ModelManagement.Project.CurrentProject() creates

 

an instance of the CurrentProject class.

Input

Argument

Example

See Also

labels = p.getAttachedLabels(filePath) returns an array of label objects for a file specified using filePath.

filePath

The fully qualified path to the file within the root folder of the project.

To get a list of labels in a file in the currently open Simulink project, use the following commands.

1Create an instance of the CurrentProject class.

p = Simulink.ModelManagement.Project.CurrentProject();

2Create a fully qualified path for the file.

Note The use of the getRootDirectory method in this step is optional.

file = fullfile(p.getRootDirectory, 'work', 'myExample.c');

3Use the getAttachedLabels method. labels = p.getAttachedLabels(file);

Simulink.ModelManagement.Project.CurrentProject

7-328

Simulink.ModelManagement.Project.CurrentProject.detac

Purpose

Remove a label from a file in the currently open Simulink project

Syntax p = Simulink.ModelManagement.Project.CurrentProject()

p.detachLabelFromFile(filePath,labelObj)

Description p = Simulink.ModelManagement.Project.CurrentProject() creates an instance of the CurrentProject class.

Input

Argument

Example

p.detachLabelFromFile(filePath,labelObj) removes a label from a file specified using filePath using the label object labelObj .

filePath

The fully qualified path to the file from which the label is to be removed.

labelObj

The label object used to remove the label from the file.

To remove a label from a file labelled with review status Approved, use the following commands.

1Create an instance of the CurrentProject class.

p = Simulink.ModelManagement.Project.CurrentProject();

2Create a fully qualified path for the file.

Note The use of the getRootDirectory method in this step is optional.

file = fullfile(p.getRootDirectory, 'work', 'myExample.c');

3Create a label object.

labelObj = Simulink.ModelManagement.Project.Label('Review','Approve

7-329

Simulink.ModelManagement.Project.CurrentProject.detachLabe

4Use the detachLabelFromFile method. p.detachLabelFromFile(file,labelObj);

See Also Simulink.ModelManagement.Project.CurrentProject

7-330

Simulink.ModelManagement.Project.CurrentProject.create

Purpose

Syntax

Description

Input

Argument

Examples

Create a label in a category in the currently open Simulink project

p = Simulink.ModelManagement.Project.CurrentProject() labelObj = Simulink.ModelManagement.Project.Label(categoryName

,labelName);

p.createLabel(labelObj)

p = Simulink.ModelManagement.Project.CurrentProject() creates an instance of the CurrentProject class.

labelObj =

Simulink.ModelManagement.Project.Label(categoryName,labelName); creates a label object named labelObj for the category categoryName.

p.createLabel(labelObj) creates the label in the category.

If the category for the new label does not exist, it is created with the label object.

categoryName

The name of the category in which the new label is to be added.

labelName

The name of the new label.

To create a new label John in category Owner in the currently open Simulink project, use the following commands.

1Create an instance of the CurrentProject class.

p = Simulink.ModelManagement.Project.CurrentProject();

2Create a label object.

labelObj= Simulink.ModelManagement.Project.Label('Owner','John');

3Add the label to the category.

7-331

Simulink.ModelManagement.Project.CurrentProject.createLabe

p.createLabel(labelObj);

See Also Simulink.ModelManagement.Project.CurrentProject

7-332

Simulink.ModelManagement.Project.CurrentProject.create

Purpose

Create a category in the currently open Simulink project

Syntax p = Simulink.ModelManagement.Project.CurrentProject()

p.createCategory(categoryName)

Description p = Simulink.ModelManagement.Project.CurrentProject() creates an instance of the CurrentProject class.

Input

Argument

Examples

See Also

p.createCategory(categoryName) creates a category named categoryName in the currently open Simulink project.

The new category is created immediately. If you are using a version control tool for your project, you must commit the resulting changes to the .SimulinkProject folder to source control.

categoryName

The name of the new category.

To create a new category Owner in the currently open Simulink project, use the following commands.

1Create an instance of the CurrentProject class.

p = Simulink.ModelManagement.Project.CurrentProject();

2Use the createCategory method. p.createCategory('Owner');

Simulink.ModelManagement.Project.CurrentProject

7-333

Simulink.ModelManagement.Project.CurrentProject.close

Purpose

Close the currently open Simulink project

Syntax

p = Simulink.ModelManagement.Project.CurrentProject()

 

p.close

Description

p = Simulink.ModelManagement.Project.CurrentProject() creates

 

an instance of the CurrentProject class.

 

p.close closes the currently open Simulink project.

Example

To close a currently open Simulink project, use the following commands.

 

1 Create an instance of the CurrentProject class.

 

p = Simulink.ModelManagement.Project.CurrentProject();

 

2 Use the close method.

 

p.close;

See Also

Simulink.ModelManagement.Project.CurrentProject

7-334

Simulink.ModelManagement.Project.CurrentProject.attach

Purpose

Add a label to a file in the currently open Simulink project

Syntax p = Simulink.ModelManagement.Project.CurrentProject()

p.attachLabelToFile(filePath,labelObj)

Description p = Simulink.ModelManagement.Project.CurrentProject() creates an instance of the CurrentProject class.

Input

Argument

Example

p.attachLabelToFile(filePath,labelObj) adds a label to a file specified using filePath using the label object labelObj .

filePath

The fully qualified path to the file to which the label is to be attached.

labelObj

The label object used to attach the label to the file.

To attach a label to a file in the currently open Simulink project with a review status Approved, use the following commands.

1Create an instance of the CurrentProject class.

p = Simulink.ModelManagement.Project.CurrentProject();

2Create a fully qualified path for the file.

Note The use of the getRootDirectory method in this step is optional.

file = fullfile(p.getRootDirectory, 'work', 'myExample.c');

3Create a label object.

labelObj = Simulink.ModelManagement.Project.Label('Review','Approve

7-335

Simulink.ModelManagement.Project.CurrentProject.attachLabe

4Use the attachLabelToFile method. p.attachLabelToFile(file,labelObj);

See Also Simulink.ModelManagement.Project.CurrentProject

7-336

Simulink.ModelManagement.Project.CurrentProject.addFil

Purpose

Add a file to the currently open Simulink project

Syntax p = Simulink.ModelManagement.Project.CurrentProject()

p.addFileToProject(filePath)

Description p = Simulink.ModelManagement.Project.CurrentProject() creates an instance of the CurrentProject class.

Input

Argument

Example

See Also

p.addFileToProject(filePath) adds a file on the specified filePath to the currently open Simulink project.

filePath

The fully qualified path to the file within the root folder of the project.

To add a file to the currently open Simulink project, use the following commands.

1Create an instance of the CurrentProject class.

p = Simulink.ModelManagement.Project.CurrentProject();

2Create a fully qualified path for the file.

Note The use of the getRootDirectory method in this step is optional.

file = fullfile(p.getRootDirectory, 'work', 'newshortcut.m');

3Use the addFileToProject method. p.addFileToProject(file);

Simulink.ModelManagement.Project.CurrentProject

7-337

Simulink.ModelManagement.Project.CurrentProject.removeCat

Purpose

Remove a category from the currently open Simulink project

Syntax p = Simulink.ModelManagement.Project.CurrentProject()

p.removeCategory(categoryName)

Description p = Simulink.ModelManagement.Project.CurrentProject() creates an instance of the CurrentProject class.

p.removeCategory(categoryName) removes the category.

Input

Argument

Examples

See Also

categoryName

The name of the category that is to be removed.

To remove a category Owner from the currently open Simulink project, use the following commands.

1Create an instance of the CurrentProject class.

p = Simulink.ModelManagement.Project.CurrentProject();

2Remove the category. p.removecategory('Owner');

Simulink.ModelManagement.Project.CurrentProject

7-338

Simulink.ModelManagement.Project.CurrentProject.remov

Purpose

Remove a file from the currently open Simulink project

Syntax p = Simulink.ModelManagement.Project.CurrentProject()

p.removeFileFromProject(filePath)

Description p = Simulink.ModelManagement.Project.CurrentProject() creates an instance of the CurrentProject class.

Input

Argument

Example

See Also

p.removeFileFromProject(filePath) removes a file on the specified filePath from the currently open Simulink project.

filePath

The fully qualified path to the file within the root folder of the project.

To remove a file from the currently open Simulink project, use the following commands.

1Create an instance of the CurrentProject class.

p = Simulink.ModelManagement.Project.CurrentProject();

2Create a fully qualified path for the file.

Note The use of the getDirectory method in this step is optional.

file = fullfile(p.getRootDirectory, 'work', 'newshortcut.m');

3Use the removeFileFromProject method. p.removeFileFromProject(file);

Simulink.ModelManagement.Project.CurrentProject

7-339

Simulink.ModelManagement.Project.CurrentProject.removeLab

Purpose

Remove a label from a category in the currently open Simulink project

Syntax

p = Simulink.ModelManagement.Project.CurrentProject()

 

labelObj =

 

Simulink.ModelManagement.Project.Label(categoryName

 

,labelName);

 

p.removeLabel(labelObj)

Description

p = Simulink.ModelManagement.Project.CurrentProject() creates

 

an instance of the CurrentProject class.

 

labelObj =

 

Simulink.ModelManagement.Project.Label(categoryName,labelName);

 

creates a label object named labelObj in category categoryName.

 

p.removeLabel(labelObj) removes the label from the category.

Input

categoryName

Argument

The name of the category from which the label is to be removed.

 

 

labelName

 

The name of the label.

Examples

To remove a label John from category Owner in the currently open

 

Simulink project, use the following commands.

1Create an instance of the CurrentProject class.

p = Simulink.ModelManagement.Project.CurrentProject();

2Create a label object.

labelObj= Simulink.ModelManagement.Project.Label('Owner','John');

3Remove the label from the category. p.removeLabel(labelObj);

7-340

Simulink.ModelManagement.Project.CurrentProject.remov

See Also Simulink.ModelManagement.Project.CurrentProject

7-341

Simulink.ModelManagement.Project.CurrentProject.setProjectN

Purpose

Change the name of the currently open Simulink project

Syntax p = Simulink.ModelManagement.Project.CurrentProject()

p.setProjectName(newName)

Description p = Simulink.ModelManagement.Project.CurrentProject() creates an instance of the CurrentProject class.

Input

Argument

Example

See Also

p.setProjectName(newName) changes the name of the currently open Simulink project to the specified newName.

The name change occurs immediately within your current project. If you are using a version control tool for your project, you must commit the changes to the .SimulinkProject folder to source control.

newName

The new specified name for an open Simulink project that replaces the existing name.

To rename the currently open Simulink project to myProject, use the following commands.

1Create an instance of the CurrentProject class.

p = Simulink.ModelManagement.Project.CurrentProject();

2Use the setProjectName method. p.setProjectName('myProject');

Simulink.ModelManagement.Project.CurrentProject

7-342

Simulink.ModelManagement.Project.CurrentProject.expor

Purpose

Export Simulink project to Zip file

Syntax

p = Simulink.ModelManagement.Project.CurrentProject()

 

export(p, filename.zip)

 

export(p, filename.zip, definitionType)

Description

p = Simulink.ModelManagement.Project.CurrentProject() creates

 

an instance of the CurrentProject class.

 

export(p, filename.zip) exports the project p to the Zip file specified

 

in filename. filename can be a file name, in which case Simulink

 

exports the file to the current folder, or a fully qualified path name.

 

export(p, filename.zip, definitionType) exports the project

 

using the specified definitionType for the project definition files. If

 

you do not specify definitionType, the project’s current setting

 

is used. Use the definitionType export option if you want

 

to change project definition file management from the type

 

selected when the project was created. definitionType can be

 

Simulink.ModelManagement.Project.DefinitionFiles.SingleFile

 

or

 

Simulink.ModelManagement.Project.DefinitionFiles.MultiFile.

 

MultiFile is better for avoiding merging issues on shared projects.

 

SingleFile is faster but is likely to cause merge issues when two users

 

both submit changes in the same project to a source control tool.

Example

To export the currently open Simulink project to a Zip file, use the

 

following commands.

 

1 Create an instance of the CurrentProject class.

 

p = Simulink.ModelManagement.Project.CurrentProject();

 

2 Use the export method.

 

export(p, 'myfilename.zip')

See Also

Simulink.ModelManagement.Project.CurrentProject

7-343

Simulink.Mask

Purpose

Control masks programmatically

Description Use an instance of Simulink.Mask class to perform the following operations.

Create, copy, and delete masks

Create, edit, and delete mask parameters

Determine the block that owns the mask

Get workspace variables defined for a mask

Methods

addParameter

Add a parameter to a mask

 

copy

Copy a mask from one block to

 

 

another

 

create

Create a mask on a Simulink

 

 

block

 

delete

Unmask a block and delete the

 

 

mask from memory

 

get

Get a block mask as a mask object

 

getOwner

Determine the block that owns a

 

 

mask

 

getParameter

Get a mask parameter using its

 

 

name

 

getWorkspaceVariables

Get all the variables defined in

 

 

the mask workspace for a masked

 

 

block

 

numParameters

Determine the number of

 

 

parameters in a mask

7-344

Simulink.Mask

 

removeAllParameters

Remove all existing parameters

 

 

from a mask

 

set

Set the properties of an existing

 

 

mask

How To

• “Control Masks Programmatically”

7-345

Simulink.Mask.addParameter

Purpose

Add a parameter to a mask

Syntax

p = Simulink.Mask.get(blockName)

 

p.addParameter(Name,Value)

Description

p = Simulink.Mask.get(blockName) gets the mask on the block

 

specified by blockName as a mask object.

 

p.addParameter(Name,Value) appends a parameter to the mask. If

 

you do not specify name–value pairs as arguments with this command,

 

Simulink creates an unnamed mask parameter with control type set

 

to edit.

Input

blockName

Arguments

The handle to the block or the path to the block inside the model.

 

 

Name-Value Pair Arguments

 

Specify optional comma-separated pairs of Name,Value arguments,

 

where Name is the argument name and Value is the corresponding

 

value. Name must appear inside single quotes (' '). You can

 

specify several name and value pair arguments in any order as

 

Name1,Value1,...,NameN,ValueN.

 

Type

 

Type of control that is used to specify the value of this parameter.

 

Default: edit

 

TypeOptions

 

The options that are displayed within a popup control or in a

 

promoted parameter. This field is a cell array.

 

Default: empty

 

Name

7-346

Simulink.Mask.addParameter

The name of the mask parameter. This name is assigned to the mask workspace variable created for this parameter.

Default: empty

Prompt

Text that identifies the parameter on the Mask Parameters dialog box.

Default: empty

Value

The default value of the mask parameter in the Mask Parameters dialog box.

Default: Type specific; depends on the Type of the parameter

Evaluate

Option to specify whether parameter must be evaluated.

Default: 'on'

Tunable

Option to specify whether parameter is tunable.

Default: 'on'

Enabled

Option to specify whether user can set parameter value.

Default: 'on'

Visible

7-347

Simulink.Mask.addParameter

Examples

See Also

Option to set whether mask parameter is hidden or visible to the user.

Default: 'on'

Callback

Container for MATLAB code that executes when user makes a change in the Mask Parameters dialog box and clicks Apply.

Default: empty

TabName

The name of the tab in the Mask Parameters dialog box where the parameter appears.

Default: empty

1Get mask as an object using a masked block’s path. p = Simulink.Mask.get('myModel/Subsystem');

2Add a parameter to the mask without specifying name–value pairs for parameter attributes.

p.addParameter;

3Add a mask parameter of type popup that cannot be evaluated and appears on a tab named Properties in the Mask Parameters dialog box.

p.addParameter('Type','popup','TypeOptions',{'Red' 'Blue' 'Green'},'Ev

Simulink.Mask

7-348

Simulink.Mask.copy

Purpose

Copy a mask from one block to another

Syntax

pSource = Simulink.Mask.get(srcBlockName)

 

pDest = Simulink.Mask.create(destBlockName)

 

pDest.copy(pSource)

Description

pSource = Simulink.Mask.get(srcBlockName) gets the mask on the

 

source block specified by blockName as a mask object.

 

pDest = Simulink.Mask.create(destBlockName) creates an empty

 

mask on the destination block specified by destBlockName.

 

pDest.copy(pSource) overwrites the destination mask with the source

 

mask.

Input

srcBlockName

Arguments

 

The handle to the source block or the path to the source block

 

 

inside the model.

 

 

 

 

 

Note The source block should be masked.

 

 

 

 

destBlockName

 

 

The handle to the destination block or the path to the destination

 

 

block inside the model.

 

 

 

 

 

Note The destination block should have an empty mask.

 

 

Otherwise, the copied mask will overwrite the non-empty mask.

Examples

 

 

1 Create an empty mask on the destination block using the block’s path.

 

pDest = Simulink.Mask.create('myModel/Subsystem');

 

2 Get source mask as an object using the source block’s path.

7-349

Simulink.Mask.copy

pSource = Simulink.Mask.get('myModel/Abs');

3Make the destination mask a copy of the source mask. pDest.copy(pSource);

See Also

Simulink.Mask

7-350

Simulink.Mask.create

Purpose

Create a mask on a Simulink block

Syntax p = Simulink.Mask.create(blockName)

Description p = Simulink.Mask.create(blockName) creates an empty mask on the block specified by blockName. If the specified block is already masked, an error message appears.

Input

Arguments

Examples

See Also

blockName

The handle to the block or the path to the block inside the model.

1Create a mask using a block’s handle.

Note In the model, select the mask to block.

p = Simulink.Mask.create(gcbh);

2Create a mask using the block’s path.

p = Simulink.Mask.create('myModel/Subsystem');

Simulink.Mask

7-351

Simulink.Mask.delete

Purpose

Unmask a block and delete the mask from memory

Syntax p = Simulink.Mask.get(blockName)

p.delete

Description p = Simulink.Mask.get(blockName) gets the mask on the block specified by blockName as a mask object.

p.delete unmasks the block and deletes the mask from memory.

Input

Arguments

Examples

See Also

blockName

The handle to the block or the path to the block inside the model.

1Get mask as an object using a masked block’s path. p = Simulink.Mask.get('myModel/Subsystem');

2Unmask the block using the mask object and delete the mask from memory.

p.delete;

Simulink.Mask

7-352

Simulink.Mask.get

Purpose

Get a block mask as a mask object

Syntax p = Simulink.Mask.get(blockName)

Description p = Simulink.Mask.get(blockName) gets the mask on the block specified by blockName as a mask object. If the specified block is not masked, a null value returns.

Input

Arguments

Examples

See Also

blockName

The handle to the block or the path to the block inside the model.

1Get mask as an object using a masked block’s handle.

Note In the model, select the masked block.

p = Simulink.Mask.get(gcbh);

2Get mask as an object using a masked block’s path. p = Simulink.Mask.get('myModel/Subsystem');

Simulink.Mask

7-353

Simulink.Mask.getOwner

Purpose

Determine the block that owns a mask

Syntax p = Simulink.Mask.get(blockName)

p.getOwner

Description p = Simulink.Mask.get(blockName) gets the mask on the block specified by blockName as a mask object.

p.getOwner returns the interface to the block that owns the mask.

Input

Arguments

Examples

See Also

blockName

The handle to the block or the path to the block inside the model.

1Get mask as an object using a masked block’s path. p = Simulink.Mask.get('myModel/Subsystem');

2Get the interface to the block that owns the mask. p.getOwner;

Simulink.Mask

7-354

Simulink.Mask.getParameter

Purpose

Get a mask parameter using its name

Syntax p = Simulink.Mask.get(blockName)

param = p.getParameter(paramName)

Description p = Simulink.Mask.get(blockName) gets the mask on the block specified by blockName as a mask object.

param = p.getParameter(paramName) returns the number of parameters in the mask.

Input

Arguments

Examples

See Also

blockName

The handle to the block or the path to the block inside the model.

paramName

The name of the parameter you want to get.

1Get mask as an object using a masked block’s path. p = Simulink.Mask.get('myModel/Subsystem');

2Get a mask parameter by using its name. param = p.getParameter('intercept');

Simulink.Mask

7-355

Simulink.Mask.getWorkspaceVariables

Purpose

Get all the variables defined in the mask workspace for a masked block

Syntax

p = Simulink.Mask.get(blockName)

 

vars = p.getWorkspaceVariables

Description

p = Simulink.Mask.get(blockName) gets the mask on the block

 

specified by blockName as a mask object.

 

vars = p.getWorkspaceVariables returns as a structure all the

 

variables defined in the mask workspace for the masked block.

Input

blockName

Arguments

The handle to the block or the path to the block inside the model.

 

Examples

1 Get mask as an object using a masked block’s path.

 

p = Simulink.Mask.get('myModel/Subsystem');

2Get all the variables defined in the mask workspace for the masked block.

vars = p.getWorkspaceVariables;

See Also

Simulink.Mask

7-356

Simulink.Mask.numParameters

Purpose

Determine the number of parameters in a mask

Syntax p = Simulink.Mask.get(blockName)

p.numParameters

Description p = Simulink.Mask.get(blockName) gets the mask on the block specified by blockName as a mask object.

p.numParameters returns the number of parameters in the mask.

Input

Arguments

Examples

See Also

blockName

The handle to the block or the path to the block inside the model.

1Get mask as an object using a masked block’s path. p = Simulink.Mask.get('myModel/Subsystem');

2Get the number of parameters in the mask. p.numParameters;

Simulink.Mask

7-357

Simulink.Mask.removeAllParameters

Purpose

Remove all existing parameters from a mask

Syntax p = Simulink.Mask.get(blockName)

p.removeAllParameters

Description p = Simulink.Mask.get(blockName) gets the mask on the block specified by blockName as a mask object.

p.removeAllParameters deletes all existing parameters from the mask.

Input

Arguments

Examples

See Also

blockName

The handle to the block or the path to the block inside the model.

1Get mask as an object using a masked block’s path. p = Simulink.Mask.get('myModel/Subsystem');

2Delete all existing parameters from the mask. p.removeAllParameters;

Simulink.Mask

7-358

Simulink.Mask.set

Purpose

Set the properties of an existing mask

Syntax

p = Simulink.Mask.get(blockName)

 

p.set(Name,Value)

Description

p = Simulink.Mask.get(blockName) gets the mask on the block

 

specified by blockName as a mask object.

 

p.set(Name,Value) sets mask properties that you specify using

 

name–value pairs as arguments.

Input

blockName

Arguments

The handle to the block or the path to the block inside the model.

 

 

Name-Value Pair Arguments

 

Specify optional comma-separated pairs of Name,Value arguments,

 

where Name is the argument name and Value is the corresponding

 

value. Name must appear inside single quotes (' '). You can

 

specify several name and value pair arguments in any order as

 

Name1,Value1,...,NameN,ValueN.

 

Type

 

Text used as title for mask documentation that user sees on

 

clicking Help in the Mask Parameters dialog box.

 

Default: empty

 

Description

 

Text used as summary for mask documentation that user sees on

 

clicking Help in the Mask Parameters dialog box.

 

Default: empty

 

Help

7-359

Simulink.Mask.set

Text used as body text for mask documentation that user sees on clicking Help in the Mask Parameters dialog box.

Default: empty

Initialization

MATLAB code that initializes the mask.

Default: empty

SelfModifiable

Option to set whether the mask can modify itself during simulation.

Default: 'off'

Display

MATLAB code that draws the mask icon.

Default: empty

IconFrame

Option to specify whether the mask icon appears inside a visible block frame.

Default: 'on'

IconOpaque

Option to set the mask icon as opaque or transparent.

Default: 'on'

RunInitForIconRedraw

7-360

Simulink.Mask.set

Examples

See Also

Option to specify whether Simulink should run mask initialization before executing the mask icon commands.

Default: 'off'

IconRotate

Option to specify icon rotation.

Default: 'none'

PortRotate

Option to specify port rotation.

Default: 'default'

IconUnits

Option to specify whether mask icon is autoscaled, normalized, or scaled in pixels.

Default: 'autoscale'

1Get mask as an object using a masked block’s path. p = Simulink.Mask.get('myModel/Subsystem');

2Modify the mask so that its mask icon is transparent and its documentation summarizes what it does.

p.set('IconOpaque','off','Type','Random number generator','Descript

Simulink.Mask

7-361

Simulink.MaskParameter

Purpose

Description

Methods

How To

Manipulate mask parameters programmatically

Use an instance of Simulink.MaskParameter to set the properties of mask parameters.

set

Set properties of mask

 

parameters

• “Control Masks Programmatically”

7-362

Simulink.MaskParameter.set

Purpose

Set properties of mask parameters

Syntax

Simulink.MaskParameter.set(Name,Value)

Description

Simulink.MaskParameter.set(Name,Value) sets the properties of

 

a mask parameter.

Input

Name-Value Pair Arguments

Arguments

Specify optional comma-separated pairs of Name,Value arguments,

 

where Name is the argument name and Value is the corresponding

 

value. Name must appear inside single quotes (' '). You can

 

specify several name and value pair arguments in any order as

 

Name1,Value1,...,NameN,ValueN.

 

Type

 

Type of control that is used to specify the value of this parameter.

 

Default: edit

 

TypeOptions

 

The options that are displayed within a popup control or in a

 

promoted parameter. This field is a cell array.

 

Default: empty

 

Name

 

The name of the mask parameter. This name is assigned to the

 

mask workspace variable created for this parameter.

 

Default: empty

 

Prompt

 

Text that identifies the parameter on the Mask Parameters dialog.

7-363

Simulink.MaskParameter.set

Default: empty

Value

The default value of the mask parameter in the Mask Parameters dialog.

Default: Type specific; depends on the Type of the parameter

Evaluate

Option to specify whether parameter must be evaluated.

Default: 'on'

Tunable

Option to specify whether parameter is tunable.

Default: 'on'

Enabled

Option to specify whether user can set parameter value.

Default: 'on'

Visible

Option to set whether mask parameter is hidden or visible to the user.

Default: 'on'

Callback

Container for MATLAB code that executes when user makes a change in the Mask Parameters dialog and clicks Apply.

Default: empty

7-364

Simulink.MaskParameter.set

Examples

See Also

TabName

The name of the tab in the Mask Parameters dialog where the parameter appears.

Default: empty

1Get mask as an object using a masked block’s path. p = Simulink.Mask.get('myModel/Subsystem');

2Get a mask parameter. a = p.Parameters(1);

3Edit mask parameter so it is of type popup, cannot be evaluated, and appears on a tab named Properties in the Mask Parameters dialog.

a.set('Type','popup','TypeOptions',{'Red' 'Blue' 'Green'},'Evaluate

Simulink.Mask | Simulink.MaskParameter

7-365

Simulink.MaskParameter.set

7-366

8

Model and Block

Parameters

“Model Parameters” on page 8-2

“Common Block Parameters” on page 8-96

“Block-Specific Parameters” on page 8-109

“Mask Parameters” on page 8-259

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]