Main Content

Simulink.BlockDiagram.addBusToVector

通过将总线添加到向量块中,将虚拟总线信号转换为向量信号

Description

例子

[[目的地,,,,BustovectorBlocks,,,,ignoredBlocks] = 金宝appsimulink.blockdiagram.addbustovector(模型搜索模型,不包括任何库块,以隐式用作向量使用的总线信号,并返回搜索结果。

[[目的地,,,,BustovectorBlocks,,,,ignoredBlocks] = 金宝appsimulink.blockdiagram.addbustovector(模型,,,,包括searches a model, and if包括true,包括在搜索库中隐含用作向量的总线信号。

例子

[[目的地,,,,BustovectorBlocks,,,,ignoredBlocks] = 金宝appsimulink.blockdiagram.addbustovector(模型,,,,包括,,,,报告searches a model, and if报告是调成错误的,然后函数插入巴士到矢量块进入每个总线,该总线在其搜索的任何块中用作向量。插入替代了将总线作为向量的隐式使用,将总线显式转换为向量。信号的源和目标块不变。

如果Simulink.BlockDiagram.addBusToVectoradds巴士到矢量blocks to the model or any library, the function changes the saved copy of the diagram.

如果Simulink.BlockDiagram.addBusToVectorchanges a library block, the change affects every instance of that block in every model that uses the library.

[[目的地,,,,BustovectorBlocks,,,,ignoredBlocks] = 金宝appsimulink.blockdiagram.addbustovector(模型,,,,包括,,,,报告,,,,严格searches a model, and if严格true,,,,the function checks for input bus signals used implicitly as vectors that are fed into one of these blocks. These blocks cannot take virtual bus signals, but they can accept nonvirtual bus signals:

  • 延迟

  • 选择器

  • 任务

  • Vector Concatenate

  • Reshape

  • Permute Dimensions

例子

全部收缩

ModelEX_BUS_TO_VECTORsimulates correctly, but the input to the Gain block is a bus, while the output is a vector. The Gain block implicitly converts the bus to a vector.

打开模型。

open_system(fullfile(matlabroot,'examples',,,,'金宝appsimulink',,,,'main',,,,...'ex_bus_to_vector'))

识别被视为向量的公共汽车。

[blocks] = 金宝appsimulink.blockdiagram.addbustovector(...'ex_bus_to_vector'
### Processing block diagram 'ex_bus_to_vector' ### Number of blocks left that are connected to a bus being used as a vector: 2 ### Done processing block diagram 'ex_bus_to_vector' blocks = 1×2 struct array with fields: BlockPath InputPort LibPath

了解Simulink.BlockDiagram.addBusToVector公交信号被视为矢量configuration parameter, see管理公共汽车向量转换

ModelEX_BUS_TO_VECTORsimulates correctly, but the input to the Gain block is a bus, while the output is a vector. The Gain block implicitly converts the bus to a vector.

打开模型。

open_system(fullfile(matlabroot,'examples',,,,'金宝appsimulink',,,,'main',,,,...'ex_bus_to_vector'))

插入巴士到矢量blocks.

When you use functionSimulink.BlockDiagram.addBusToVector报告调成错误的,该功能保存模型。创建模型的可写副本EX_BUS_TO_VECTOR,,,,this example uses thesave_system功能。

save_system('ex_bus_to_vector',,,,'ex_bus_to_vector_blocks'); [blocks,busToVectors] = Simulink.BlockDiagram.addBusToVector(...'ex_bus_to_vector_blocks',真假);

Gain块不再隐式将总线转换为向量。插入巴士到矢量block performs the conversion explicitly. The巴士到矢量block is virtual and does not affect simulation results, code generation, or performance.

了解Simulink.BlockDiagram.addBusToVector公交信号被视为矢量configuration parameter, see管理公共汽车向量转换

输入参数

全部收缩

模型名称或句柄,指定为字符向量,字符串标量或数字标量。

数据类型:双倍的|char|细绳

Search library blocks, specified as错误的ortrue

  • 错误的- 仅搜索模型中的块。

  • true-Search library blocks for bus signals used implicitly as vectors.

Specify as the second argument.

数据类型:逻辑

Choice to report results without changing the model, specified as错误的ortrue

  • 错误的-Update the model by inserting巴士到矢量隐式用作向量的总线信号的块。

  • true- 报告搜索结果,但不要更改模型。

Specify as the third argument. Also specify the模型and包括arguments.

数据类型:逻辑

检查输入总线信号,隐式用作供学者,这些向量可以接受可以接受非虚拟但不接受虚拟的总线信号,指定为错误的ortrue。如果严格true,,,,the function checks for input bus signals used implicitly as vectors that are fed into one of these blocks. These blocks cannot take virtual bus signals, but they can accept nonvirtual bus signals.

  • 延迟

  • 选择器

  • 任务

  • Vector Concatenate

  • Reshape

  • Permute Dimensions

指定为第四个参数。您还必须指定模型,,,,包括,,,,and报告arguments.

数据类型:逻辑

输出参数

全部收缩

Blocks connected to buses that treat buses as vectors, returned as an array of structures. Each structure in the array contains these fields:

  • BlockPath- 字符向量指定通往总线连接的块的路径。

  • inputport-Integer specifying the input port to which the bus connects.

  • libpath- 如果块是库块实例,以及包括true,字段值是通往源库块的路径。否则,libpath是空的 ([[])。

巴士到矢量blocks added by function, specified as a cell array. If报告是调成错误的,单元阵列包含每个路径巴士到矢量阻止添加到替换用作向量的总线的功能。否则,BustovectorBlocks是空的 ([[])。

Cases where function cannot insert巴士到矢量block, specified as an array of structures. Each structure in the array contains these fields:

  • BlockPath- 字符向量指定通往总线连接的块的路径。

  • inputport-Integer specifying the input port to which the bus connects.

这些案例发生在巴士到矢量无法插入,因为输入虚拟总线信号由具有混合属性的元素组成。

Tips

  • 在执行此功能之前:

    1. 确保该模型无错误地编译。

    2. 保存模型。

  • 备份模型和任何库,然后用报告调成错误的

  • To preview the effects of the change on blocks in all models, callSimulink.BlockDiagram.addBusToVector包括调成trueand报告调成true。然后,检查在目的地output argument.

也可以看看

在R2007A中引入