Search code examples
matlabmathcadtransfer-function

mathcad / matlab 3D plot of transfer function


I have a problem plotting a 3D plot of my transfer function. In matlab I have tryed this:

 [T,w] = meshgrid(1:1:32,1:1:100);
sys2=20*log((1-w.*(T./2)./w.*T).*(((2.56.*(w.^2)+1.6.*w+1)./(0.0008.*(w.^6)+0.0124.* (w.^5)+0.173.*(w.^4)+(w.^3)))./1+(((2.56.*(w.^2)+1.6.*w+1)./(0.0008.*(w.^6)+0.0124.*(w.^5)+0.173.*(w.^4)+(w.^3))))));
 surf(T,w,sys2);

But I get this error:

  ??? Error using ==> surf at 78
  X, Y, Z, and C cannot be complex.

What could be wrong please? Or can anyone tell me how to plot this in Mathcad? Thank you.


Solution

  • You can't plot a complex number versus two independent variables -- you would need four axes.

    What you can do is:

    1. Use two separate figures (or two subplots in the same figure) to plot real part and imaginary part. In Matlab,

      surf(T,w,real(sys2));
      figure %// create new figure for the other graph
      surf(T,w,imag(sys2));
      
    2. Alternatively, plot absolute value and phase:

      surf(T,w,abs(sys2));
      figure %// create new figure for the other graph
      surf(T,w,angle(sys2));
      
    3. A more exotic possibility is to use z axis for absolute value and colour for phase, in the same graph:

      surf(T,w,abs(sys2),angle(sys2)); %// fourth argument of surf specifies colour