Main Content

Square Root of Negative Values

This example shows how to compute the square root of a negative-valued input signal as complex-valued output.

ans = 

  Simulink.SimulationOutput:
                   tout: [51x1 double] 

     SimulationMetadata: [1x1 Simulink.SimulationMetadata] 
           ErrorMessage: [0x0 char] 

By setting the Function to sqrt and Output signal type to complex, the block produces the correct result of 0 + 10i for an input of -100. If you change the Output signal type to auto or real, the block outputs NaN.