Matlab Simulink 枚举映射

Matlab Simulink enumeration mapping

我想在 simulink 中映射 2 个枚举列表,以便使用它们的名称而不是它们的值可以很容易地看到这两个映射之间的联系。如何做到这一点?

谢谢!

示例:
操作:

classdef(Enumeration) Actions < Simulink.IntEnumType
    enumeration
        Off(1)
        PowerOn(2)
        PowerOff(3)
    end
end 

州:

classdef(Enumeration) States < Simulink.IntEnumType
    enumeration
        START(1000)
        RUNNING(1002)
        STOPPED(1003)
        OFF(1004)
    end
end 

连接是这样的:

States.START -> Actions.PowerOn
States.RUNNING -> Actions.PowerOn
States.STOPPED -> Actions.PowerOff
States.OFF -> Actions.Off

要实现这一点,通常的做法是使用这样的 Multiport Switch. Use the values for States as data port indices and the Actions as Enumerated Constants

多端口交换机的设置应如下所示:

我已经使信号的数据类型可见,可以看到我们将数据类型 States 的信号映射到数据类型 Actions 的信号。