文档

Variable-Size Signal Basics

关于Variable-Size Signals

模拟金宝app®信号可以是标量,向量(1-D),矩阵(2-D)或N-D。有关这些类型的信号的信息,请参阅Signal Basicsin the金宝appSimulink用户指南

Si金宝appmulink变量大小信号是一个信号,其大小(尺寸中的元素数)除了其值之外,在模型模拟过程中还可以改变。但是,在模拟过程中,尺寸的数量不会改变。此功能使您可以使用不同的资源,约束和环境建模系统。

Creating Variable-Size Signals

You can create variable-size signals in your Simulink model by using:

  • Switch or Multiport Switch blocks with different input ports having fixed-size signals with different sizes. The output is a variable-size signal.

  • 选择器块和Starting and ending indices (port)indexing option. The index port signal can specify different subregions of the input data signal which produce an output signal of variable size as the simulation progresses.

  • 带有输出端口的S功能块为可变大小的信号配置。输出不仅包括值,还包括信号的尺寸。

可变大小的信号如何传播

在Simuli金宝appnk环境中,可变大小的信号可以在模型执行过程中以两种方式之一更改其大小:

  • 在模型执行的每个步骤中。

    Various blocks in the model modify the sizes of the signals during execution of the output method.

  • Only during initialization of conditionally executed subsystems.

    Size changes occur during distinct mode-switching events in subsystems such as Action, Enable, and Function-Call subsystems.

您可以通过考虑带有状态的离散2-TAP滤波器块来查看关键差异。

离散的2-TAP过滤器

假设该滤波器的输入信号尺寸从模拟过程中从4变为1。单位延迟块的状态何时以及如何从4到1适应以继续处理输入是模棱两可的。为了确保一致性,两个单位延迟块必须同步更改其状态行为。为了防止歧义,Simulink通常会取消块,金宝app其状态的数量取决于在执行过程中任何点变化的信号大小在上下文中的输入信号大小。

相比之下,考虑相同的离散2-Tap Filter block in a Function-Call subsystem. Assume that this subsystem is using the second way to propagate variable-size signals. In this case, the size of the input signal changes from 4 to 1 only at the initialization of the subsystem. At initialization, the subsystem resets all of its states (including the states of the two Unit Delay blocks) to their initial values. Resetting the subsystem ensures no ambiguity on the assignment of states to the input signal of the filter.

Mode-Dependent Variable-Size Signalsshows how you can use the two ways of propagating variable-size signals in a complementary fashion to model complex systems.

Programmatically Determine Whether Signal Line Has Variable Size

此示例显示了如何在命令提示符或脚本中使用命令来确定信号线是否具有可变大小。在子系统或参考模型的大型模型或层次结构中,使用此技术来确定信号是否由于上游块而具有可变大小。

示例模型sldemo_varsize_basiccontains a signal一个那是一个下游Switch堵塞。在命令提示下使用命令来确定是否一个has a variable size.

  1. 打开the example model.

  2. Select theblock whose output signal is labeled一个

  3. 在命令提示符下,将模型设置为编译状态(类似于Diagram Update)。

    sldemo_varsize_basic([],[],[],'compile'

  4. Get a handle to the block output port.

    porthandles = get_param(gcb,'portHandles'); outPortHandle = portHandles.Outport;

  5. 查询程序化参数汇编portdimensionsmodeof the output port.

    varSize = get_param(outPortHandle,“汇编港口模板”
    varSize = 1

    价值of the variablevarSizeis1,这表明信号一个具有可变大小。

    价值0表示信号没有可变大小。

  6. 终止模型汇编。

    sldemo_varsize_basic([],[],[],'学期'

Empty Signals

空信号是一个长度的信号0。例如,大小的信号[0],,,,[0x3],,,,[2x0],,,,一个nd[2x0x3]都是空信号。金宝appSimulink允许使用可变大小信号的空信号,并支持大多数元素操作。金宝app但是,Simuli金宝appnk不支持修改信号尺寸的块金宝app的空信号。不受金宝app支持的块包括沿指定维度的重塑,置入和总和。

可变大小信号的子系统初始化

The initial signal size from anOutportblock in a conditionally executed subsystem varies depending on the parameters you select.

如果您设置可变大小信号的传播尺寸parameter in the parent subsystem toDuring execution, 这初始输出parameter for the Output block must not exceed the maximum size of the input port. If the初始输出parameter value is:

初始输出parameter 初始输出信号大小
A nonscalar matrix 初始输出信号大小是初始输出范围。
标量 The initial output signal size is a scalar.
默认[] 初始输出大小是一个空信号(尺寸都是零)。

如果您设置可变大小信号的传播尺寸parameter in the parent subsystem toOnly when enabling, 这初始输出parameter for the Output block must be a scalar value.

  • When size is repropagated for the input of theOutport块,使用标量参数值的标量扩展设置初始输出值。

  • If the初始输出参数是默认值[],S金宝appimulink将初始输出视为接地值。

  • 如果模型在开始时间没有激活父子系统(t = 0),,,,the current size of the subsystem output corresponding to theOutport块设置为最大尺寸。

  • 当其母体子系统重新传播信号大小时,子系统变量大小输出信号的值也将重置为其初始输出参数值。

Related Topics