I am having an issue with the interaction of the Matlab function block in the Simulink with my model block. Below you can also find the picture. I have created a Matlab function with three inputs and 1 output. Since in the MatLab function block, I have solved a differential equation, it has complex expressions in the form of for example.


This generates the output of complex data types from the function block. When passing this to the integrator which is the input to my plant, I can not run the Simulink due to the error

    "Cannot pass the complex value to non-complex location"

I tried changing the data types of the integrator, then the same thing happens to other blocks in the Simulink. I also tried using absolute values, which of course gives real numbers, but turns out to be a very large number and generates high magnitude. I really need help in solving this issue. Can anyone help me in this/

Thanks in advance.

enter image description here

  • $\begingroup$ Are these building blocks supposed to be in the time domain or the s-domain? $\endgroup$ – A_A Jun 1 at 10:05
  • $\begingroup$ they are in time domain. But I am wondering the logic behind this question?. Also, plant can be in the form of the transfer function. $\endgroup$ – Prateek Tiwari Jun 1 at 10:20
  • $\begingroup$ The logic behind the question is to clarify if the model expects an s-plane type of variable to be passed around, or if it expects a single or vector of time domain values. Is it possible to talk a little bit more about what is in the plant or function block? Complex numbers are used to express phase differences. If you are passing around only 1 "thing" (time domain), then you are going to have to find a way of combining the two "things" ($\Re(z), \Im(z)$ for some $z$ variable) into one. $\endgroup$ – A_A Jun 1 at 11:15

The data type of the signal must be fixed in Simulink. Since you use a square root of a real signal, the output will be real if the data is positive, imaginary if negative. Simulink cannot allow that.

The workaround is to use a complex signal and feed it to the square root block. Then the output will always be complex.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.