フィルターのクリア

Using Simulink.IntEnumType in the switch case block.

16 ビュー (過去 30 日間)
jason
jason 2015 年 8 月 13 日
回答済み: Chaitali Gondhalekar 2015 年 8 月 17 日
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!

回答 (1 件)

Chaitali Gondhalekar
Chaitali Gondhalekar 2015 年 8 月 17 日
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!

カテゴリ

Help Center および File ExchangeString についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by