Search code examples
matlabsimulinkcomplex-numberstransfer-function

Complex-value denominator in Simulink


I want to plot the step response of a transfer function. The equation is 1/as^2 + bs + c (sorry, I don't know how to write fractions here). I was given two sets of values, and corresponding equations for the transfer function parameters:

a1 = [-2, -1 + 2i] (i is the imaginary unit)

a2 = [-3, -1 - 2i]

a = 1

b = (a1 + a2)

c = (a1 * a2)

The first set of values (-2, -3) works perfectly both in Matlab and Simulink. The problem starts when I want to type in the imaginary numbers in the Simulink's denominator like so :

Denominator problem

In Matlab I can do this with:

a1 = -1 + 2i;
a2 = -1 - 2i;
a = 1;
b = (a1 + a2);
c = (a1 * a2);

num = 1;
den = [a b c];
s = tf(num, den);
step(s);

Yet in Simulink, it always gives me that error. I know there is the 'simout' and 'simin' methods, but I was wondering if it can be done manually?


Solution

  • The transfer function you are implementing in MATLAB is not the same as the transfer function you are trying to implement in Simulink.

    In MATLAB you have tf = 1/(s^2 - 2s + 5). In Simulink you are trying to implement tf = 1/(s^2 -3s + (6-2i)).

    Having a transfer function with complex coefficients doesn't really make sense. Simulink won't allow you to do it, while MATLAB will throw various warning all of which mean it can't handle what you are trying to do,

    >> den = [1 -3 6-2i]
    den =
       1.0000 + 0.0000i  -3.0000 + 0.0000i   6.0000 - 2.0000i
    >> s = tf(num, den);
    Warning: The numerator or denominator of this transfer function has complex-valued
    coefficients. 
    > In tf (line 360) 
    >> step(s)
    Warning: The data cannot be plotted because it is not real valued. 
    > In wavepack.waveform/draw (line 65)
      In wrfc.plot/draw (line 17)
      In wrfc.plot/init_listeners>LocalRefreshPlot (line 79)
      In DynamicSystem/stepplot (line 131)
      In DynamicSystem/step (line 92)
    

    Note also the there are no such things as simin and simout methods. There is a block for importing signals from MATLAB and another for exporting signals back to MATLAB, that by default read/write MATLAB variables named simin/simout respectively. But they are not methods.