MATLAB: Does the Multiport Switch block in Simulink 7.4 (R2009b) report a data-type mismatch when one of the two complex constants fed into it is 0+0j

simulink

I am using a Multiport Switch block in my attached Simulink 7.4 (R2009b) model. Two complex constants, namely 1+1j and 0+0j are fed into this block as inputs. When I update my model, I get the following error:
Complex signal mismatch. Input port 3 of 'datatype_mismatch/Multiport Switch' expects a signal of numeric type complex. However, it is driven by a signal of numeric type real

Best Answer

In MATLAB 7.9 (R2009b), 0+0j evaluates to the real number 0 and not to a complex number. Thus, when 0+0j is used in a Constant block, the block will evaluate 0+0j in MATLAB, and will get a real number of 0 as a result.
To work around this issue, open up the dialog for the Constant block corresponding to the constant value 0+0j. Then, set the 'Constant value' field to complex(0,0) instead of 0+0j.