Filter löschen
Filter löschen

Using Simulink.IntEnumType in the switch case block.

16 Ansichten (letzte 30 Tage)
jason
jason am 13 Aug. 2015
Attempting to use an enumeration in a switch case block. Per the block instructions I enter the "enumeration('enumclass')" in the block mask input, but it raises this error. I'm using the BasicColors from the demo, and the enumeration function works when ran from the command window.
Can anyone tell me what I'm missing?
classdef BasicColors < Simulink.IntEnumType enumeration Red(0) Yellow(1) Green(2) end end
Thanks!

Antworten (1)

Chaitali Gondhalekar
Chaitali Gondhalekar am 17 Aug. 2015
I understand that you want to use Enumerated Data Type with Switch Case block in Simulink.
You can specify the "Case conditions" in the switch case block mask as a cell array.
For Example, {BasicColors.Red, BasicColors.Yellow, BasicColors.Blue}
This case condition implies that port 1 is run when the input is "BasicColors.Red" and port 2 is run when the input is "BasicColors.Yellow" and port 3 is run when the input is "BasicColors.Blue".
The attached folder "enumTestTS" contains a Simulink model file "enum_ex_TS" that uses enumerated data type "BasicColors" with Switch Case block. The enumerated data type is defined in class file "BasicColors.m".
Hope this helps!

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by