求助!!怎样用Matlab显示图像的频谱?
做了一个带阻滤波器,因为不知道噪声的频率所以无法选择滤波器的带宽和半径,想看一下图像的频谱,可是不会显示,哪位高人给俺指点一下啊??
谢谢!! 自定义函数
function =cftbyfft(wt,t,flag)
if nargin==2;flag=1;end
N=length(t);
T=t(length(t))-t(1);
dt=T/N;
W0=fft(wt);
W=dt*W0;
df=1/T;
n=0:1:(N-1);
if flag==0
n=-N/2:(N/2-1);
W=fftshift(W);
end
f=n*df;
AW=abs(W);
if nargout==0
plot(f,AW);grid,xlabel('频率f');ylabel('|w(f)|')
end
调用自定义函数
M=5;
tend=1;
T=10;
N=2^M;
dt=T/N;
n=0:N-1;
t=n*dt;
w=zeros(size(t,2),1);
Tow=find((tend-t)>0);
w(Tow,1)=ones(length(Tow),1);%
plot(t,w,'b','LineWidth',2.5),title('Time Waveform');xlabel('t --- >')
=cftbyfft(w,t,0);
ff=f+eps;
AWW=abs(sin(pi*ff)./(pi*ff));
plot(f,AW,'b-',ff,AWW,'r:')
title('Aliasing caused by undersampling')
xlabel('f --- >');ylabel('|W(f)|'),legend('by FFT','Theoretical')
页:
[1]