Simulink.io.FileType class

Package: Simulink.io

Base class for file types

Description

Simulink.io.FileType is the base class for Simulink.io.FileType objects. In your class definition file, you must subclass your object from this base class. Simulink® requires direct inheritance from FileType. Subclassing allows you to use the implementation methods and service methods provided by this class to build your object. Type this syntax as the first line of your class definition file to directly inherit from the Simulink.io.FileType base class, where ObjectName is the name of your object:

classdef ObjectName < Simulink.io.FileType

The Simulink.io.FileType class is a handle class.

Class Attributes

Abstract
true
HandleCompatible
true

For information on class attributes, see Class Attributes (MATLAB).

Properties

expand all

File name of file that contains custom signals for import to Signal Editor, specified as a character array.

Attributes:

GetAccess
public
SetAccess
public

Data Types:

Methods

expand all

Examples

collapse all

Define a Simulink.io.FileType class.

classdef MySignalMatFile < Simulink.io.FileType

end

Interact with FileType using specialized functions. This example refers to the open('Simulink.io.CreateSignals') sample file.

Get contents of foo.mat.

fileName = 'foo.mat';
aReader = Simulink.io.CreateSignals(fileName);
resultOfWhos = whos(aReader);

Import custom signals from foo.mat.

aFileType = Simulink.io.CreateSignals('foo.mat');
out = import(aFileType);

Load the custom signals in foo.mat.

aFileType = Simulink.io.CreateSignals('foo.mat');
out = load(aFileType);

Load a variable from foo.mat.

aFileType = Simulink.io.CreateSignals('foo.mat');
out = loadAVariable( aFileType,'bar');

Export the signals from Signal Editor.

ds = Simulink.SimulationData.Dataset;
ds = ds.addElement(timeseries([1:10]',[1:10]'),'Siganl1');
ds = ds.addElement(timeseries([1:10]',[11:20]'),'Siganl2');
ds = ds.addElement(timeseries([1:10]',[21:30]'),'Siganl3');

aReader = Simulink.io.CreateSignals('myFileToExport.mat');

didWrite = aReader.export(filePath,{'ds'},{ds},0);

Introduced in R2020a