필터 지우기
필터 지우기

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 CenterFile Exchange에서 String에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by