请求帮助
:@(郁闷请求帮助Sample Text两个程序一样的思想,一样的算法,一样的参数,为什么结果不一样?:'(
第一个:
L1=0.4;
L2=0.4;
m=20;
n=20;
k0=1.25;
k=2*pi*400/340;
a=2/k;
M=m*n;
s=(L1*L2)/M;
S=L1*L2;
for i=1:M
a1=rem(i,m);
b1=(i-a1)/m;
if a1~=0
x1=(a1-1)*L1/m;
y1=(n-b1-1)*L2/n;
else
x1=(m-1)*L1/m;
y1=(n-b1)*L2/n;
end
u(i)=x1+L1/(2*m);
w(i)=y1+L2/(2*n);
for j=1:M
a2=rem(j,m);
b2=(j-a2)/m;
if a2~=0
x2=(a2-1)*L1/m;
y2=(n-b2-1)*L2/n;
else
x2=(m-1)*L1/m;
y2=(n-b2)*L2/n;
end
if j~=i
r=sqrt((x2-x1)^2+(y2-y1)^2);
R(i,j)=k0*k0*s*s*sin(k0*r)/(2*pi*S*k0*r);
else
R(i,j)=k0*k0*s*s/(2*pi*S);
end
end
end
=eig(R);
y=v(:,(397));
for i=1:30
theta(i)=(i-1)*pi/29;
x11=0.2;
y11=0.2-a*cos(pi*(i-1)/29);
z11=a*sin(pi*(i-1)/29);
for j=1:M
r(j)=sqrt((u(j)-x11)^2+(w(j)-y11)^2+(z11)^2);
g(j)=k*s*(0+1i)*exp((0-1i)*k*r(j))/(2*pi*r(j));
G(i,j)=g(j);
end
F=g*y;
rho(i)=abs(F);
Y(i)=angle(F);
end
subplot(1,2,1)
polar(theta,rho,'-o')
subplot(1,2,2)
plot(theta,Y,'-o')
第二个:调用两个M函数
fenbutuxing:
k=2*pi*1500/340;
R=2/k;
for i=1:30
theta(i)=(i-1)*pi/29;
x=0.2;
y=0.2-R*cos(theta(i));
z=R*sin(theta(i));
q(i)=fenbumotai(4,x,y,z);
r(i)=abs(q(i));
ang(i)=angle(q(i));
end
subplot(1,2,1)
polar(theta,r,'-o')
subplot(1,2,2)
plot(theta,ang,'-o')
fenbumotai:
function F=fenbumotai(I,d,e,f)
L1=0.4;
L2=0.4;
m=20;
n=20;
k=2*pi*400/340;
M=m*n;
s=(L1*L2)/M;
S=L1*L2;
for j=1:M
a1=rem(j,m);
b1=(j-a1)/m;
if a1~=0
x1=(a1-1+0.5)*L1/m;
y1=(n-b1-1+0.5)*L2/n;
else
x1=(m-1+0.5)*L1/m;
y1=(n-b1+0.5)*L2/n;
end
r1=sqrt((e-x1)^2+(d-y1)^2+(f)^2);
g(j)=k*s*(1i)*exp((-1i)*k*r1)/(2*pi*r1);
end
g;
F=g*mode(I);
mode:
function y=mode(x)
L1=0.4;
L2=0.4;
m=20;
n=20;
k=2*pi*400/340;
k0=0.5/L1;
M=m*n;
s=(L1*L2)/M;
S=L1*L2;
for i=1:M
a1=rem(i,m);
b1=(i-a1)/m;
if a1~=0
x1=(a1-1)*L1/m;
y1=(n-b1-1)*L2/n;
else x1=(m-1)*L1/m;
y1=(n-b1)*L2/n;
end
for j=1:M
a2=rem(j,m);
b2=(j-a2)/m;
if a2~=0
x2=(a2-1)*L1/m;
y2=(n-b2-1)*L2/n;
else x2=(m-1)*L1/m;
y2=(n-b2)*L2/n;
end
if j~=i
r=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
R(i,j)=k0*k0*s*s*sin(k0*r)/(2*pi*S*k0*r);
else
R(i,j)=k0*k0*s*s/(2*pi*S);
end
end
end
=eig(R);
y=v(:,(M-x+1));
页:
[1]