主题:Crazy
小弟正在学习用matlab编写一个傅立叶序列的程序 当用ifft求其逆变换的时候总是matlab提示
In an assignment A(I) = B, the number of elements in B and
I must be the same.
Error in ==> cal070312 at 34
f(x)=ifft(b,100)
小弟写的源程序代码为:
function cal0703()
%初始化
L=1;
l=0.04;
h=9e-7;
N=100;
W=[];
b=[];
kn=0:N/2;
for i=1:length(kn)
W(i)=exp(-kn(i)^2*l^2/4)*h^2*l/2/sqrt(pi);
end
% r
%b(1) 为实际b(0) 类推
r=randn(1,1000);
b(1)=sqrt(2*pi*L*W(1)*r(1));
xb=pi*N/L;
w_xb=exp(-xb^2*l^2/4)*h^2*l/2/sqrt(pi);
b(N/2+1)=sqrt(2*pi*L*w_xb*r(end));
for(j=1:N/2-1)
cc=complex(r(j),r(j+N/2));
b(j+1)=sqrt(2*pi*L*W(j+1))*cc;
end
len=length(b);
bn=[]; %-1到-N/2+1的b值
for(m=1:len-2)
b_i=conj(b(m+1));
bn=[b_i,bn];
end
b=[bn,b]
这可以产生一个序列
后面要把它做ifft变换的时候不会做了
我的写的:
for x=1:N
f(x)=ifft(b,N)
end(错误就在这三行)
哪位大哥大姐99我
In an assignment A(I) = B, the number of elements in B and
I must be the same.
Error in ==> cal070312 at 34
f(x)=ifft(b,100)
小弟写的源程序代码为:
function cal0703()
%初始化
L=1;
l=0.04;
h=9e-7;
N=100;
W=[];
b=[];
kn=0:N/2;
for i=1:length(kn)
W(i)=exp(-kn(i)^2*l^2/4)*h^2*l/2/sqrt(pi);
end
% r
%b(1) 为实际b(0) 类推
r=randn(1,1000);
b(1)=sqrt(2*pi*L*W(1)*r(1));
xb=pi*N/L;
w_xb=exp(-xb^2*l^2/4)*h^2*l/2/sqrt(pi);
b(N/2+1)=sqrt(2*pi*L*w_xb*r(end));
for(j=1:N/2-1)
cc=complex(r(j),r(j+N/2));
b(j+1)=sqrt(2*pi*L*W(j+1))*cc;
end
len=length(b);
bn=[]; %-1到-N/2+1的b值
for(m=1:len-2)
b_i=conj(b(m+1));
bn=[b_i,bn];
end
b=[bn,b]
这可以产生一个序列
后面要把它做ifft变换的时候不会做了
我的写的:
for x=1:N
f(x)=ifft(b,N)
end(错误就在这三行)
哪位大哥大姐99我