czk108 发表于 2011-4-28 15:18

多频率成分FFT谱分析的问题

本帖最后由 czk108 于 2011-4-28 15:28 编辑

R=;%共81个值
f1=92e5.*R./81 ;%距离换算成频率
f0=23e9;c=3e8;
fs=92e9/5400;
deltf=1e6;
t=1:1024;
chapais=0.5*cos(2*pi*f1(1)*t/fs)+0.5*cos(2*pi*f1(2)*t/fs)+0.5*cos(2*pi*f1(3)*t/fs)+0.5*cos(2*pi*f1(4)*t/fs)+0.5*cos(2*pi*f1(5)*t/fs)+...
    0.5*cos(2*pi*f1(6)*t/fs)+0.5*cos(2*pi*f1(7)*t/fs)+0.5*cos(2*pi*f1(8)*t/fs)+0.5*cos(2*pi*f1(9)*t/fs)+0.5*cos(2*pi*f1(10)*t/fs)+...
    0.5*cos(2*pi*f1(11)*t/fs)+0.5*cos(2*pi*f1(12)*t/fs)+0.5*cos(2*pi*f1(13)*t/fs)+0.5*cos(2*pi*f1(14)*t/fs)+0.5*cos(2*pi*f1(15)*t/fs)+...
    0.5*cos(2*pi*f1(16)*t/fs)+0.5*cos(2*pi*f1(17)*t/fs)+0.5*cos(2*pi*f1(18)*t/fs)+0.5*cos(2*pi*f1(19)*t/fs)+0.5*cos(2*pi*f1(20)*t/fs)+...
    0.5*cos(2*pi*f1(21)*t/fs)+0.5*cos(2*pi*f1(22)*t/fs)+0.5*cos(2*pi*f1(23)*t/fs)+0.5*cos(2*pi*f1(24)*t/fs)+0.5*cos(2*pi*f1(25)*t/fs)+...
    0.5*cos(2*pi*f1(26)*t/fs)+0.5*cos(2*pi*f1(27)*t/fs)+0.5*cos(2*pi*f1(28)*t/fs)+0.5*cos(2*pi*f1(29)*t/fs)+0.5*cos(2*pi*f1(30)*t/fs)+...
    0.5*cos(2*pi*f1(31)*t/fs)+0.5*cos(2*pi*f1(32)*t/fs)+0.5*cos(2*pi*f1(33)*t/fs)+0.5*cos(2*pi*f1(34)*t/fs)+0.5*cos(2*pi*f1(35)*t/fs)+...
    0.5*cos(2*pi*f1(36)*t/fs)+0.5*cos(2*pi*f1(37)*t/fs)+0.5*cos(2*pi*f1(38)*t/fs)+0.5*cos(2*pi*f1(39)*t/fs)+0.5*cos(2*pi*f1(40)*t/fs)+...
    0.5*cos(2*pi*f1(41)*t/fs)+0.5*cos(2*pi*f1(42)*t/fs)+0.5*cos(2*pi*f1(43)*t/fs)+0.5*cos(2*pi*f1(44)*t/fs)+0.5*cos(2*pi*f1(45)*t/fs)+...
    0.5*cos(2*pi*f1(46)*t/fs)+0.5*cos(2*pi*f1(47)*t/fs)+0.5*cos(2*pi*f1(48)*t/fs)+0.5*cos(2*pi*f1(49)*t/fs)+0.5*cos(2*pi*f1(50)*t/fs)+...
    0.5*cos(2*pi*f1(51)*t/fs)+0.5*cos(2*pi*f1(52)*t/fs)+0.5*cos(2*pi*f1(53)*t/fs)+0.5*cos(2*pi*f1(54)*t/fs)+0.5*cos(2*pi*f1(55)*t/fs)+...
    0.5*cos(2*pi*f1(56)*t/fs)+0.5*cos(2*pi*f1(57)*t/fs)+0.5*cos(2*pi*f1(58)*t/fs)+0.5*cos(2*pi*f1(59)*t/fs)+0.5*cos(2*pi*f1(60)*t/fs)+...
    0.5*cos(2*pi*f1(61)*t/fs)+0.5*cos(2*pi*f1(62)*t/fs)+0.5*cos(2*pi*f1(63)*t/fs)+0.5*cos(2*pi*f1(64)*t/fs)+0.5*cos(2*pi*f1(65)*t/fs)+...
    0.5*cos(2*pi*f1(66)*t/fs)+0.5*cos(2*pi*f1(67)*t/fs)+0.5*cos(2*pi*f1(68)*t/fs)+0.5*cos(2*pi*f1(69)*t/fs)+0.5*cos(2*pi*f1(70)*t/fs)+...
    0.5*cos(2*pi*f1(71)*t/fs)+0.5*cos(2*pi*f1(72)*t/fs)+0.5*cos(2*pi*f1(73)*t/fs)+0.5*cos(2*pi*f1(74)*t/fs)+0.5*cos(2*pi*f1(75)*t/fs)+...
    0.5*cos(2*pi*f1(76)*t/fs)+0.5*cos(2*pi*f1(77)*t/fs)+0.5*cos(2*pi*f1(78)*t/fs)+0.5*cos(2*pi*f1(79)*t/fs)+0.5*cos(2*pi*f1(80)*t/fs)+...
    0.5*cos(2*pi*f1(81)*t/fs);%81个正弦信号叠加
figure(1)
plot(chapais,'k');
N=1024;
S=abs(fft(chapais,N));
% S=fftshift(S1);
f=(0:N-1)*fs/N;
figure(2)
plot(f(1:N/2),S(1:N/2),'k');
figure(3)
% stem(S(n1:n2),'.');
stem(f(1:N/2),S(1:N/2),'.k');
axis();title('局部放大FFT谱');
figure(4)
% stem(S(n1:n2),'.');
plot(f(1:N/2),S(1:N/2),'k');
axis();title('局部放大FFT谱');
disp('index')
index=find(S>=max(S(2:N-1)))
index11=(index(index<N/2))
if(S(index11+1)<S(index11-1))
    n1=index11-14
    n2=index11+11
else
    n1=index11-6
    n2=index11+19
end
f=(index11-1)*fs/N   %减1?
R=3e8*f/(2*1536e6)*(1536/(fs))

%czt
% n1=index11-4;
% n2=index11+2;
M=100;                           % czt细化倍数
A=exp(j*2*pi*n1/N);            % czt参数设置
W=exp(-j*2*pi*(n2-n1)/(M*N));
spec=czt(chapais,M,W,A);               % czt变换
a=abs(spec);                     
index1=((0:length(spec)-1)'*(n2-n1)/length(spec))+n1;
f1=(index1-1).*fs/N;
figure(5),plot(f1,a,'k');         %绘制czt细化后频谱
title('CZT细化');
grid on;
figure(6),stem(f1,a,'.k');         %绘制czt细化后频谱
title('CZT细化');
grid on;
% 寻找峰值
index=find(a>=max(a));
ag=a(index)
m=n1+(n2-n1)/M*(index-1);   %峰值对应谱线号
fff=(m-1)*fs/N
R=3e8*fff/(2*1536e6)*(1536/(fs))

理想中信号chapais的FFT谱应该是幅值相同、带宽与实际频率f1的宽度范围对应的理想谱,而实际运行得到的频谱确不一样,会是什么原因呢?望高手帮忙解答   还有帮忙看下程序中有没有问题   谢谢

页: [1]
查看完整版本: 多频率成分FFT谱分析的问题