Reputation: 768
This is my code so far:
sigma = -8:0.1:0;
omega = -10:0.1:10;
[x,y] = meshgrid(sigma, omega);
s = x + y*j;
zz = (5^2)./(s.^2 + 2*0.4*5.*s + 5^2);
xx = real(s);
yy = imag(s);
surf(xx,yy,zz);
I am getting the error that I can not use a complex variable in the surf
function. I know the issue is in the zz
variable, but I do not know how to find the magnitude of a complex function. Here is exactly what I am trying to do: https://i.sstatic.net/4X2Qx.png
Upvotes: 1
Views: 675
Reputation: 8459
Use abs
to get the magnitude of a complex number.
zz = (5^2)./(s.^2 + 2*0.4*5.*s + 5^2);
xx = real(s);
yy =imag(s);
surf(xx,yy,abs(zz));
Upvotes: 3