Main Content

Simulink.io.BaseWorkspace Class

Namespace: Simulink.io

Read data in format used by base workspace

Since R2021a

Description

Simulink.io.BaseWorkspace inherits from the Simulink.io.FileType base class. It reads data formatted in a format used by the base workspace. Use base workspace file types to move data to and from the base workspace to a function, automated process, or user interface. To import data from the base workspace, use this command.

classdef BaseWorkspace < Simulink.io.FileType

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

Class Attributes

Abstract
false
HandleCompatible
true

For information on class attributes, see Class Attributes.

Properties

expand all

Base workspace reader, specified as a character array.

Attributes:

GetAccess
public
SetAccess
public

Data Types: char | string

Methods

expand all

Examples

collapse all

Read data in base workspace format from file, foo.mat.

Set up a timeseries variable, ts. If ts is a variable in the workspace, the object ignores fileName.

ts = timeseries([0;9]);

Set up reader.

aReader = Simulink.io.BaseWorkspace();
resultOfWhos = whos( aReader );

Load the reader, which has no inputs.

varsOnFileStruct = load(aReader);

Load one variable.

var = loadAVariable(aReader,'ts');

Import the file.

importedVars = import(aReader);

Export to a file.

ds = Simulink.SimulationData.Dataset;
ds = ds.addElement(timeseries([1:10]',[1:10]'),'Signal1');
ds = ds.addElement(timeseries([1:10]',[11:20]'),'Signal2');
ds = ds.addElement(timeseries([1:10]',[21:30]'),'Signal3');
%filePath is ignored, must be provided because the API ruleset
filePath = '';
didWrite = aReader.export(filePath,{'ds'},{ds},0);

Version History

Introduced in R2021a