Main Content

loadAVariableImpl

Class:Simulink.io.FileType
Package:Simulink.io

Load specified variable from MAT-file

Syntax

varOut = loadAVariableImpl(MATfile,varName)

Description

varOut= loadAVariableImpl(MATfile,varName)loads the specified variable from the MAT-file.

Input Arguments

expand all

File name of the MAT-file that contains signals to load, specified as a character array.

Data Types:char

Variable name to load, specified as a character array.

Data Types:char

Output Arguments

expand all

Found variables to load, returned as a cell array of signal variables of supported types. For more information on supported types, seeChoose a Base Workspace and MAT-File Format.

Examples

expand all

SubclassFileTypeclass and implementloadAVariableImplmethod.

classdefMySignalMatFile < Simulink.io.FileType

Implement the static methodloadAVariableImpl.

methodsfunctionstructOut = loadAVariableImpl(obj,varName)% Assume loading a variable from a MAT-file.data = load(obj.FileName,varName);ifisempty(fieldnames(data)) error([varName' was not found on the file.']);endifisSimulinkSignalFormat(data.(varName)) structOut.(varName) =...data.(varName);elseerror([varName' is not a Simulink signal format.']);endendend

版本历史

Introduced in R2020a