MATLAB: Do I receive a run time error when executing a model with MATLAB Function block with real inputs and complex outputs in Simulink 7.7 (R2011a)

simulink

I receive a run time error in executing an EML block that consists of real inputs and complex outputs.

Best Answer

Since the MATLAB Function block generates an equivalent C code for the MATLAB algorithm that you implement, you must ensure that the input data type is forced to be complex.
For example:
x = complex(0,0)
% x is the input variable that is used by a function say ROOTS to
% calculate both real and/or complex roots
This step will impose that there is a match in output data type and size that is created based on the input signal.