Using Simulink.IntEnumType in the switch case block.
조회 수: 18 (최근 30일)
이전 댓글 표시
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!
댓글 수: 0
답변 (1개)
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!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Types에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!