令直角坐标和极坐标原点重合
第一种:不用matlab自带函数
close all;
clear all;
clc;
N=128;
M=128;
xstep = 2/(N-1);%x方向上步长
ystep = 2/(M-1);%y方向上步长
[x,y] = meshgrid(-1:xstep:1,-1:ystep:1); % 2D 矩形网格
circle = x.^2 + y.^2; % rho^2=x.^2+y.^2 =circle
Z=x+1i*y; % 方便求半径和相位角
rho=abs(Z);%半径
theta=angle(Z);%角度 相位角
第二种:用matlab自带函数
close all;
clear all;
clc;
N=128;
M=128;
xstep = 2/(N-1);%x方向上步长
ystep = 2/(M-1);%y方向上步长
[X, Y] = meshgrid(-1:xstep:1,-1:ystep:1); % 2D 矩形网格
[theta, rho] = cart2pol(X, Y);