Simulink.Bus.objectToCell
Create cell array of bus information from Simulink.Bus
objects
Description
Examples
Create Cell Arrays Containing Bus Object Information
Create cell arrays that define Simulink.Bus
objects.
Open the example model named BusConversion
.
mdl = "BusConversion";
open_system(mdl)
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
objs
— Simulink.Bus
objects
cell array of Simulink.Bus
object names
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'})
scope
— Data dictionary
Simulink.data.Dictionary
object
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
C
— Simulink.Bus
object information
cell array of cell arrays
Simulink.Bus
object information, specified as a cell
array of cell arrays. Each subordinate cell array contains these
Simulink.Bus
object
properties:
Bus name
Header file
Description
Data scope
Alignment
Preserve element dimensions
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:
Element name
Dimensions
Data type — When this field specifies a
Simulink.Bus
object, the specification does not include theBus:
prefix. This prefix is optional when you set the data type of aSimulink.BusElement
object to aSimulink.Bus
object.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.
Complexity
Sampling mode
Dimensions mode
Minimum
Maximum
Units
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 R2007aR2020b: Simulink.BusElement
objects no longer support the SampleTime
property
The SampleTime
property of Simulink.BusElement
objects is no longer supported.
BusElement
objects that specify a sample time cause an error during
compile. To remove the sample time specification from a BusElement
object,
set its SampleTime
to -1
.
Simulink.Bus.cellToObject
continues to accept cell arrays that
specify sample time for bus elements. Simulink.Bus.objectToCell
,
Simulink.Bus.save
, and Simulink.Bus.createObject
continue to return cell arrays or arrays that include the sample time when it is noninherited.
When the sample time is inherited (-1
), they omit it. Similarly, the
Type Editor and Model Explorer omit the sample time when it is
inherited.
To specify the sample time for an element of a bus, use the
SampleTime
block parameter of corresponding blocks. For example,
you can use In Bus Element, Out Bus Element, and Signal
Specification blocks to specify sample time.
R2016b: Simulink.BusElement
objects will no longer support the SamplingMode
property
The SamplingMode
property of Simulink.BusElement
objects has been removed. Scripts that use the SamplingMode
property of
Simulink.BusElement
objects continue to work. The
Simulink.Bus.cellToObject
function continues to require the
SamplingMode
field. The
Simulink.Bus.objectToCell
function continues to include the
sampling mode in the output cell arrays. When you save Simulink.Bus
object
definitions to functions that use cell arrays, the cell arrays continue to include the
sampling mode.
In a future release, support for the SamplingMode
property will be
removed.
To specify whether a signal is sample-based or frame-based, define the sampling mode of input signals at the block level instead of at the signal level.
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)