帮忙分析一段MATLAB的FFT程序
时间:10-02
整理:3721RD
点击:
format long g;
clc;
SampleNumber=2^10;
SampleFrequency=100e6;
SingleFrequency=6.5e6;%6.5e6;
vi=load('.\data.txt');
Vin=reshape(vi,'',1)';%'
Vin=Vin-(max(Vin(70:end))+min(Vin(70:end)))/2;
figure(1);
hold on;
plot(Vin(70:SampleNumber+69));
numpt2=fix(SampleNumber/2);
Dout=Vin(70:SampleNumber+69);
Window=kaiser(SampleNumber,10)';%'
span=5;
Doutw=Dout.*Window;
DoutFFT=fft(Doutw,SampleNumber);
SumPower=(abs(DoutFFT)).*(abs(DoutFFT));
SumPower_dB=10*log10(SumPower);
[MaxdB,SingleFrequencyPoint]=max(SumPower_dB(1:numpt2));
spanh=3;
DcPower=sum(SumPower(1:span));
if SingleFrequencyPoint>span
SinglePower=sum(SumPower(SingleFrequencyPoint-span:SingleFrequencyPoint+span));
else
SinglePower=0;
end
SingleHarmonyNumber2=floor(SampleNumber/SingleFrequencyPoint);%或者为SampleFrequency/(SingleFrequency)
SingleHarmonyPower=zeros(SingleHarmonyNumber2);
SingleHarmonyPower(1)=SinglePower;
SingleHarmonyFrequency=zeros(SingleHarmonyNumber2);
SingleHarmonyFrequency(1)=SampleFrequency*(SingleFrequencyPoint)/SampleNumber;
SingleHarmonyStep=SingleFrequencyPoint;
for SingleHarmonyNumber=1:SingleHarmonyNumber2/2;
if (SingleHarmonyStep<=0) break; end
HarmonyFrequencyPoint=SingleHarmonyStep*SingleHarmonyNumber+SingleFrequencyPoint
if (HarmonyFrequencyPoint<=numpt2)
if SingleHarmonyNumber==1;
BaseHarmonyFrequencyPoint=HarmonyFrequencyPoint;
end
SingleHarmonyPower(SingleHarmonyNumber+1)=sum(SumPower(HarmonyFrequencyPoint-spanh:HarmonyFrequencyPoint+spanh));
SingleHarmonyFrequency(SingleHarmonyNumber+1)=(HarmonyFrequencyPoint)*SampleFrequency/SampleNumber;
end
end
SingleFrequency=SingleHarmonyFrequency(1);
HarmonyPowerNumber=floor(SampleNumber/SingleFrequencyPoint)/2;%或者为SampleFrequency/(SingleFrequency)/2
HarmonyPower=sum(SingleHarmonyPower(1:HarmonyPowerNumber))-SingleHarmonyPower(1);
NoisePower=sum(SumPower(1:numpt2))-DcPower-SinglePower;
ss=sqrt((sum(Dout.^2)/sum(Doutw.^2))*NoisePower*2)/SampleNumber%*sqrt(12)
HarmonyRange=floor(SampleNumber/SingleFrequencyPoint)/2;%或者为SampleFrequency/(SingleFrequency)/2
SNDR=10*log10(SinglePower/NoisePower);
THD=10*log10(HarmonyPower/SingleHarmonyPower(1))
SFDR=10*log10(SingleHarmonyPower(1)/max(SingleHarmonyPower(2:HarmonyRange)));
ENOBloc=(SNDR-1.76)/6.02;
figure(2);
hold on;
semilogx([0:numpt2-1]*SampleFrequency/SampleNumber,SumPower_dB(1:numpt2),'-r');
text_handle = text(floor(SampleFrequency/3),10, sprintf('SNDR = %4.1f dB \nENOB = %2.2f bits ',SNDR,ENOBloc), ...
'EdgeColor','red','LineWidth',3,'BackgroundColor',[1 1 1],'Margin',10);
title('FREQ DOMAIN');
xlabel('ADC FFT SPECTRUM');
ylabel('AMPLITUDE(dB)');
在论坛上下了一段程序,做ADC的FFT分析,测量SNDR,ENOB等的参数,但是看不懂里面什么意思,不知道怎么改,我的ADC仿真时100M的采样时钟,输入6.5M,65个正选周期信号,1024个采样点,12位的精度,这段程序应该怎么改啊,我改了几个参数,但是出来的结果不对啊,有效位有12.58这么多,所以我怀疑我那个参数改对,请高手帮忙看看啊 附上仿真以后的变量参数
clc;
SampleNumber=2^10;
SampleFrequency=100e6;
SingleFrequency=6.5e6;%6.5e6;
vi=load('.\data.txt');
Vin=reshape(vi,'',1)';%'
Vin=Vin-(max(Vin(70:end))+min(Vin(70:end)))/2;
figure(1);
hold on;
plot(Vin(70:SampleNumber+69));
numpt2=fix(SampleNumber/2);
Dout=Vin(70:SampleNumber+69);
Window=kaiser(SampleNumber,10)';%'
span=5;
Doutw=Dout.*Window;
DoutFFT=fft(Doutw,SampleNumber);
SumPower=(abs(DoutFFT)).*(abs(DoutFFT));
SumPower_dB=10*log10(SumPower);
[MaxdB,SingleFrequencyPoint]=max(SumPower_dB(1:numpt2));
spanh=3;
DcPower=sum(SumPower(1:span));
if SingleFrequencyPoint>span
SinglePower=sum(SumPower(SingleFrequencyPoint-span:SingleFrequencyPoint+span));
else
SinglePower=0;
end
SingleHarmonyNumber2=floor(SampleNumber/SingleFrequencyPoint);%或者为SampleFrequency/(SingleFrequency)
SingleHarmonyPower=zeros(SingleHarmonyNumber2);
SingleHarmonyPower(1)=SinglePower;
SingleHarmonyFrequency=zeros(SingleHarmonyNumber2);
SingleHarmonyFrequency(1)=SampleFrequency*(SingleFrequencyPoint)/SampleNumber;
SingleHarmonyStep=SingleFrequencyPoint;
for SingleHarmonyNumber=1:SingleHarmonyNumber2/2;
if (SingleHarmonyStep<=0) break; end
HarmonyFrequencyPoint=SingleHarmonyStep*SingleHarmonyNumber+SingleFrequencyPoint
if (HarmonyFrequencyPoint<=numpt2)
if SingleHarmonyNumber==1;
BaseHarmonyFrequencyPoint=HarmonyFrequencyPoint;
end
SingleHarmonyPower(SingleHarmonyNumber+1)=sum(SumPower(HarmonyFrequencyPoint-spanh:HarmonyFrequencyPoint+spanh));
SingleHarmonyFrequency(SingleHarmonyNumber+1)=(HarmonyFrequencyPoint)*SampleFrequency/SampleNumber;
end
end
SingleFrequency=SingleHarmonyFrequency(1);
HarmonyPowerNumber=floor(SampleNumber/SingleFrequencyPoint)/2;%或者为SampleFrequency/(SingleFrequency)/2
HarmonyPower=sum(SingleHarmonyPower(1:HarmonyPowerNumber))-SingleHarmonyPower(1);
NoisePower=sum(SumPower(1:numpt2))-DcPower-SinglePower;
ss=sqrt((sum(Dout.^2)/sum(Doutw.^2))*NoisePower*2)/SampleNumber%*sqrt(12)
HarmonyRange=floor(SampleNumber/SingleFrequencyPoint)/2;%或者为SampleFrequency/(SingleFrequency)/2
SNDR=10*log10(SinglePower/NoisePower);
THD=10*log10(HarmonyPower/SingleHarmonyPower(1))
SFDR=10*log10(SingleHarmonyPower(1)/max(SingleHarmonyPower(2:HarmonyRange)));
ENOBloc=(SNDR-1.76)/6.02;
figure(2);
hold on;
semilogx([0:numpt2-1]*SampleFrequency/SampleNumber,SumPower_dB(1:numpt2),'-r');
text_handle = text(floor(SampleFrequency/3),10, sprintf('SNDR = %4.1f dB \nENOB = %2.2f bits ',SNDR,ENOBloc), ...
'EdgeColor','red','LineWidth',3,'BackgroundColor',[1 1 1],'Margin',10);
title('FREQ DOMAIN');
xlabel('ADC FFT SPECTRUM');
ylabel('AMPLITUDE(dB)');
在论坛上下了一段程序,做ADC的FFT分析,测量SNDR,ENOB等的参数,但是看不懂里面什么意思,不知道怎么改,我的ADC仿真时100M的采样时钟,输入6.5M,65个正选周期信号,1024个采样点,12位的精度,这段程序应该怎么改啊,我改了几个参数,但是出来的结果不对啊,有效位有12.58这么多,所以我怀疑我那个参数改对,请高手帮忙看看啊 附上仿真以后的变量参数
我靠有这么复杂么?
你去看看这个:Maxim Application Note 729