Main Content

与阵列的公共汽车一起工作

Setting up a model to use an array of buses usually involves these tasks:

  1. Define the array of buses. See从非虚拟巴士创建一系列公共汽车

  2. 一个dd a subsystem for performing iterative processing on each element of the array of buses. SeePerform Iterative Processing

  3. 在迭代处理子系统中对标量算法进行建模。

    1. 在一系列公共汽车上操作(使用选择器and任务blocks).

    2. 使用总线选择器and巴士分配从子系统中的非虚拟总线中选择元素或分配元素的块。

    一个ssign Values into Arrays of Busesand从一系列巴士中选择公交元素

  4. 可选地,导入或日志总线数据。看导入总线数据andLog Arrays of Buses

The resulting model creates the array of buses and uses a subsystem to iteratively process the elements of the array.

非虚拟总线分组为一系列总线,这些总线是提供迭代处理的子系统的输入。

Perform Iterative Processing

您可以使用诸如诸如对于每个子系统,,,,While Iterator Subsystem,,,,andFor Iterator Subsystemblocks. You can use one of these blocks to perform the same kind of processing on:

  • Each bus in the array of buses

  • 公共汽车数组中选定的公共汽车子集

一个ssign Values into Arrays of Buses

如何将值分配给一系列总线中的一个或多个元素取决于您的建模要求。

  • To assign values to specified buses in an array of buses, use an任务堵塞。例如,请参阅Model Arrays of Buses

  • 要将值分配给总线中的指定元素,请使用巴士分配堵塞。访问子系统中的公共汽车,例如for-each子系统或通过从一系列巴士中选择公交车选择器堵塞。例如,请参阅将信号值分配给总线元素

    一个巴士分配block can also assign or fully replace an array of buses that is an element of a bus.

  • To assign values to elements of a bus in an array of buses, you can use aMATLABFunction堵塞。例如,请参阅分配成一系列公共汽车的元素

从一系列巴士中选择公交元素

To select a bus element from an array of buses:

  1. 用一个选择器块从公交车数组中选择一辆总线。总线的输入阵列可以具有任何维度。的输出总线选择器块是从总线的输入阵列中选择或重新排序的元素集。

  2. 用一个总线选择器块从总线中选择一个总线元件。输入的输入总线选择器街区必须是公共汽车。

例如,请参阅Model Arrays of Buses

导入总线数据

使用根Inport导入(负载)MATLAB的结构数组®时间序列一系列公共汽车的对象。您可以将部分数据导入到总线的数组中。有关更多信息,请参阅导入总线数据

你不能使用从工作区or从文件阻止导入一系列总线的数据。

Log Arrays of Buses

To export an array of buses, mark the signal for signal logging. For more information, see从模拟中保存运行时数据

笔记

金宝app®不会在快速加速器模式下引用模型中的记录信号。

要访问总线数组中特定信号的信号记录数据,请浏览结构层次结构并指定特定信号的索引。有关详细信息,请参阅访问一系列巴士信号记录数据

Root level bus outputs are not logged when you select the输出配置参数。如上所述,使用标准信号记录使用信号记录导出信号数据

请勿直接从面孔子系统内直接使用信号日志记录或总线数组。要么使用总线选择器block to select the bus element signals to log or add anOutportblock outside of the subsystem and then log that signal. For details, see每个子系统的日志信号

笔记

对于具有可变大小信号的总线数组,不支持信号记金宝app录。

初始化公共汽车阵列

To specify a unique initial value for each of the individual signals in an array of buses, you can use an array of initial condition structures. Each structure in the array initializes one of the buses.

要初始化具有结构参数的一系列总线,您可以使用:

  • 号码0。在这种情况下,公交数组中的所有单独信号都使用初始值0

  • 标量结构that represents the same hierarchy of fields and field names as the bus type. In this case, the scalar structure expands to initialize each of the individual signals in the array of buses.

  • 一个n array of structures that specifies an initial value for each of the individual signals in the array of buses.

    如果使用一系列结构,则数组中的所有结构都必须具有相同的字段层次结构。层次结构中的每个字段必须在整个数组之间具有相同的特征:

    • Field name

    • 数字数据类型,例如单身的orint32

    • 复杂

    • 方面

您不能使用部分结构。

For examples, seeInitialize Buses and Arrays of Buses Using Bus Editorand以编程方式初始化公交车数组

代码生成

公交车数组的代码生成可生产具有特定格式的结构。看代码生成for Arrays of Buses

笔记

对于具有可变大小信号的总线数组,不支持代码生成金宝app。

Related Topics