Documentation

Simulink.Bus.save

Save bus objects in MATLAB file

Syntax

Simulink.Bus.save(fileName)
Simulink.Bus.save(fileName,format)
Simulink.Bus.save(fileName,format,busNames)

Description

example

Simulink.Bus.save(fileName) saves all bus objects (instances of Simulink.Bus class) that are in the MATLAB® base workspace in a MATLAB file that contains a cell array of cell arrays. Each subordinate cell array represents a bus object and contains this data:

  • Bus name

  • Header file

  • Description

  • Data scope

  • Alignment

  • Elements

The elements field is an array containing this data for each element:

  • Element name

  • Dimensions

  • Data type

  • Sample time

  • Complexity

  • Dimensions mode

  • Minimum

  • Maximum

  • Units

  • Description

example

Simulink.Bus.save(fileName,format) saves the bus objects in a MATLAB file that contains either a cell array of bus information or the bus objects themselves.

example

Simulink.Bus.save(fileName,format,busNames) saves only those bus objects whose names appear in busNames.

Examples

collapse all

Use the Simulink.Bus.save function to save a bus object.

Define a cell array of bus object information.

busCell = { ...
        { ...
            'myBusObj', ...
            'MyHeader.h', ...
            'My description', ...
            'Exported', ...
            '-1', ...
            {{'a',1,'double',[0.2 0],'real','Frame'}; ...
            {'b',1,'double',[0.2 0],'real','Sample'}},...
            }, ...
        };

Create myBusObj bus object from the cell array.

Simulink.Bus.cellToObject(busCell);

Save the bus object in the BusCellFile1 file, in cell format.

fileName = 'BusCellFile1';
Simulink.Bus.save(fileName);

Save the bus object in bus format.

Simulink.Bus.save('BusObjFile','object');

Save myBusObj in cell format in BusCellFile2.m.

Simulink.Bus.save('BusCellFile2','cell',{'myBusObj'});

Input Arguments

collapse all

File in which to store bus objects, specified as a character vector.

Format for storing bus objects in file, specified as either 'cell' or 'object'. The cell format is more compact, but the object format is easier to read.

Bus objects to save, specified as a cell array of bus objects. Only the specified bus objects in the base workspace are saved.

Tips

Executing a MATLAB file created by Simulink.Bus.save in cell array format calls Simulink.Bus.cellToObject to recreate the bus objects and returns the new bus objects in the cell array. To suppress the creation of bus objects, specify the optional argument 'false' when you execute the MATLAB file.

Introduced before R2006a

Was this topic helpful?