MATLAB: Do I receive an error while simulating a stateflow chart which passes an enumerated data in Stateflow 7.9 (R2012a)

enumeratedstateflow

I have defined the enumerated type signal with the head file mybasiccolors.h:
Simulink.defineIntEnumType('BasicColors', ...
{'Red', 'Yellow', 'Blue'}, ...
[0;1;2], ...
'Description', 'Basic colors', ...
'DefaultValue', 'Blue', ...
'HeaderFile', 'mybasiccolors.h', ..
'DataScope', 'Imported', ...
'AddClassNameToEnumNames', true);
I want to simulate only the model but not generate code. Therefore, the "mybasiccolors.h" should not be needed during simulation stage.
In Stateflow 7.8 (R2011b), the simulation completed. But in MATLAB R2012a, it pops up error regards missing the "mybasiccolors.h" file:
Data has compiled structure or enumeration type ‘BasicColors’, which specifies customer header file ‘mybasiccolors.h’.
This custom header file must be directly or indirectly included in model’s Configuration Parameters ‘Simulation Target/Custom Code/Header file’ field.

Best Answer

This behavior is expected in R2012a. From R2012a onwards, if data in a Stateflow chart uses an enumerated type with a custom header file, you will have to include the header information in Simulation Target > Custom Code pane as documented in the followingr release note and documentation page:
If you do not have access to the header file and do not plan to generate code at all, you should be able to define the enumeration the following way (without the header file) and simulate his model:
Simulink.defineIntEnumType('BasicColors', ...
{'Red', 'Yellow', 'Blue'}, ...
[0;1;2], ...
'Description', 'Basic colors', ...
'DefaultValue', 'Blue', ...
'DataScope', 'Imported', ...
'AddClassNameToEnumNames', true);