Question

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: http://i.imgur.com/Y6Rw8y6.png

Was it helpful?

Solution

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));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top