Simulink Enumeration
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I am trying to do a simple multiport switch. My control is a numeric value.
If 1 is selected, I want my output to be 'Red'. If 2, I want 'Yellow', ect.
I have tried creating a class object for Colors. (thinking this isn't helping)
classdef Colors
properties
R = 0;
G = 0;
B = 0;
end
methods
function c = Colors(r,g,b)
c.R = r; c.G = g; c.B = b;
end
end
enumeration
Red(1, 0, 0)
Orange(1, .5, 0)
Yellow(1, 1, 0)
Green(0, 1, 0)
Blue(0, 0, 1)
Indigo(.2, 0, .8)
Violet(1, 0, 1)
end
end
thus, when I type Colors.Red, I get Red as my output.I used the Enumerated Constant, of output Colors and value Colors.Red. I get error "Initialization commands cannot be evaluated."
Any help would be great, my end goal is to pass a value out of "Red","Yellow"..ect. If I do this as a char or enumerated state I don't care.
thanks.
0 Kommentare
Antworten (2)
Fangjun Jiang
am 21 Okt. 2011
This video might be helpful. http://www.mathworks.com/support/2010b/matlab/7.11/demos/enumerations-in-r2010b.html
2 Kommentare
Kaustubha Govind
am 24 Okt. 2011
I don't think you can use this kind of enumerated class in Simulink. Simulink enumerated types need to inherit from Simulink.IntEnumType. See Defining Simulink Enumerations.
0 Kommentare
Siehe auch
Kategorien
Mehr zu String finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!