[英]Am trying to plot the magnitude of a complex function in MATLAB
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. 我收到错误,我不能在
surf
功能中使用复杂的变量。 I know the issue is in the zz
variable, but I do not know how to find the magnitude of a complex function. 我知道问题出在
zz
变量中,但我不知道如何找到复杂函数的大小。 Here is exactly what I am trying to do: http://i.imgur.com/Y6Rw8y6.png 这正是我想要做的: http : //i.imgur.com/Y6Rw8y6.png
Use abs
to get the magnitude of a complex number. 使用
abs
来获得复数的大小。
zz = (5^2)./(s.^2 + 2*0.4*5.*s + 5^2);
xx = real(s);
yy =imag(s);
surf(xx,yy,abs(zz));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.