| Contents | Index |
To generate efficient standalone code for enumerated data, you are restricted to the following operations. The examples are based on the definitions of the enumeration type LEDcolor described in Class Definition: LEDcolor.
| Example | Result |
|---|---|
xon = LEDcolor.GREEN xoff = LEDcolor.RED | xon =
GREEN
xoff =
RED |
| Example | Result |
|---|---|
xon == xoff | ans =
0 |
xon <= xoff | ans =
1 |
xon > xoff | ans =
0 |
| Example | Result |
|---|---|
double(LEDcolor.RED) | ans =
2 |
z = 2 y = LEDcolor(z) | z =
2
y =
RED |
| Example | Result |
|---|---|
m = [1 2] n = LEDcolor(m) p = n(LEDcolor.GREEN) | m =
1 2
n =
GREEN RED
p =
GREEN |
| Statement | Example | Executable Example |
|---|---|---|
if | if state == sysMode.ON
led = LEDcolor.GREEN;
else
led = LEDcolor.RED;
end | |
switch | switch button
case VCRButton.Stop
state = VCRState.Stop;
case VCRButton.PlayOrPause
state = VCRState.Play;
case VCRButton.Next
state = VCRState.Forward;
case VCRButton.Previous
state = VCRState.Rewind;
otherwise
state = VCRState.Stop;
end | |
while | while state ~= State.Ready
switch state
case State.Standby
initialize();
state = State.Boot;
case State.Boot
boot();
state = State.Ready;
end
end |
![]() | Defining and Using Enumerated Types for Code Generation | Using Enumerated Data in Control Flow Statements | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |