Main Content

Simulink.Bus.objectToCell

Create cell array of bus information from Simulink.Bus objects

Description

C = Simulink.Bus.objectToCell(objs) creates a cell array of bus information from the Simulink.Bus objects specified by objs. The objects must be in the MATLAB® base workspace.

example

C = Simulink.Bus.objectToCell(objs,scope) creates a cell array of bus information from Simulink.Bus objects in the data dictionary specified by scope.

Examples

collapse all

Create cell arrays that define Simulink.Bus objects.

Open the example model named BusConversion.

mdl = "BusConversion";
open_system(mdl)

BusConversion model

This model creates Simulink.Bus objects named TopBus and Sinusoidal.

Create cell arrays that define each object.

objects = {'TopBus','Sinusoidal'};
cells = Simulink.Bus.objectToCell(objects);
cells{1}
ans=1×7 cell array
    {'TopBus'}    {0x0 char}    {0x0 char}    {'Auto'}    {'-1'}    {'0'}    {2x1 cell}

cells{2}
ans=1×7 cell array
    {'Sinusoidal'}    {0x0 char}    {0x0 char}    {'Auto'}    {'-1'}    {'0'}    {2x1 cell}

Input Arguments

collapse all

Simulink.Bus objects, specified as a cell array of Simulink.Bus object names. Specify the object names as character vectors.

If objs is empty, the function converts all Simulink.Bus objects in the base workspace or data dictionary.

Example: cells = Simulink.Bus.objectToCell({'busObject'})

Data dictionary, specified as a Simulink.data.Dictionary object. Before you use this argument, represent the dictionary with a Simulink.data.Dictionary object by using, for example, the Simulink.data.dictionary.create or Simulink.data.dictionary.open function.

If scope is empty, the function uses the MATLAB base workspace as the source of the Simulink.Bus objects.

Example: cells = Simulink.Bus.objectToCell({'busObject'},dataDictionaryObject)

Output Arguments

collapse all

Simulink.Bus object information, specified as a cell array of cell arrays. Each subordinate cell array contains these Simulink.Bus object properties:

  1. Bus name

  2. Header file

  3. Description

  4. Data scope

  5. Alignment

  6. Preserve element dimensions

  7. Elements

The elements field is a cell array that contains this information for each of the Simulink.BusElement objects that the Simulink.Bus object references:

  1. Element name

  2. Dimensions

  3. Data type — When this field specifies a Simulink.Bus object, the specification does not include the Bus: prefix. This prefix is optional when you set the data type of a Simulink.BusElement object to a Simulink.Bus object.

  4. Sample time — The cell array contains this field when the sample time is not inherited. A noninherited sample time causes an error during model compilation. For more information, see Simulink.BusElement objects no longer support the SampleTime property.

  5. Complexity

  6. Sampling mode

  7. Dimensions mode

  8. Minimum

  9. Maximum

  10. Units

  11. Description

The order of elements in the output cell array corresponds to the order of names in the input cell array.

Tips

The inverse function is Simulink.Bus.cellToObject.

Version History

Introduced in R2007a

expand all