MATLAB: Do I receive an error if I have variables with the same name in the Stateflow chart and in the custom external code

arraychart;codecustomdimensionserrorexternalheaderstateflow

I have a Stateflow variable defined with the same name as an array in my custom code. Each has been declared with a different array size. This produces an error.
State = SS[3].State[4];}
^
Array dimensions mismatch for data State (#698).

Best Answer

This is an expected behavior of Stateflow, because the parser is not able to handle identical variable names with different sizes in Stateflow and custom code.
Currently, to work around this problem, make sure the Stateflow names and custom code names do not clash.