我是靠谱客的博主 苗条电话,最近开发中收集的这篇文章主要介绍fft频谱 matlab,matlab流水线ADC仿真FFT频谱测试【求高手搭救】,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?注册

x

小弟用matlab仿真1.5比特的十位ADC,采样率1e9

做FFT频谱测试时卡住了,求各位高手搭救

我用的FFT程序如下:

%data1=data(:,2);

%Data_in=load('ADC16.txt');

%>> plot(data1, 'DisplayName'; 'data1'; 'YDataSource'; 'data1'); figure(gcf)

%>> Data_in=data1;

fs=100e7;

DOUT_sum_uni=data;

len=length(DOUT_sum_uni);

N=len;

figure;

plot([1:N],DOUT_sum_uni);

title('TIME DOMAIN')

xlabel('SAMPLES');

ylabel('DIGITAL OUTPUT CODE');

zoom xon;

%performing FFT

DOUT_sum_uni=DOUT_sum_uni-mean(DOUT_sum_uni);

x=hann(N);

data_win=x.*DOUT_sum_uni;

x1=norm(x,1);                                 %?????ó??

Dout_spect=fft(data_win,N)/(x1);

%recalculate to dB

Dout_dB=20*log10(abs(Dout_spect));

%plot([1:N/2],Dout_dB(1:N/2));

%display the results in the frequency domain with FFT plot

figure;

maxdB=max(Dout_dB(2:N/2));

%%for TTIMD,use the following short routine,normalized to -6.5dB

%full scale.

%plot([0:numpt/2-1].*fclk/numpt,Dout_dB(1:numpt/2)-maxdB-6.5);

plot([0:N/2-1].*(fs/N),Dout_dB(1:N/2)-maxdB);

%plot([0:numpt/2-1].*(fclk/numpt),Dout_dB(1:numpt/2));

grid on;

title('FFT PLOT');

xlabel('Analog INPUT FREQUENCY(MHz)');

ylabel('AMPLITUDE(dB)');

%a1=axis;axis([a1(1) a1(2)-120 a1(4)]);

%-----------------------------------------------%

%calculate SNR,SINAD,ENOB,THD and SFDR values

%-----------------------------------------------%

%find the signal bin number, DC=bin 1

fin=find(Dout_dB(1:N/2)==maxdB);

%Span of the input freq on each side

%span=5;

%span=max(round(N/400),5);

span=max(round(N/200),5);

%approximate search span for harmonics on each side

spanh=2;

%determine power spectrum

spectP=(abs(Dout_spect)).*(abs(Dout_spect));

%find DC offset power

Pdc=sum(spectP(1:span));

%extract overall signal power

%Ps=sum(spectP(span-fin:span+fin));

Ps=sum(spectP(fin-span:fin+span));

%vector/matric to store both freq and power of signals and harmonics

Fh=[];

%the 1st element in the vector/matrix represents the signal,

%the next element reps the 2nd harmonic,etc..

Ph=[];

%find harmonic freq and power components in the FFT spectrum

for har_num=1:10

%input tones greater than fSAMPLE are aliased back into the spectrum

tone=rem((har_num*(fin-1)+1)/N,1);

if tone>0.5

%input tones greater than 0.5*fSAMPLE(after aliasing) are reflected

tone=1-tone;

end

Fh=[Fh tone];

%for this procedure to work,ensure the folded back high order harmonics

%do not overlap

%with DC or signal or lower order harmonics

har_peak=max(spectP(round(tone*N)-spanh:round(tone*N)+spanh));

har_bin=find(spectP(round(tone*N)-spanh:round(tone*N)+spanh)==har_peak);

har_bin=har_bin+round(tone*N)-spanh-1;

Ph=[Ph sum(spectP(har_bin-1:har_bin+1))];

end

%determine the total distortion power

Pd=sum(Ph(2:5));

%determine the noise power

Pn=sum(spectP(1:N/2))-Pdc-Ps-Pd;

%inband_bin=1:N/2;

%fin_bin=fin-span:fin+span;

%harnoi_bin=setdiff(inband_bin,fin_bin);

%Phn=sum(spectP(harnoi_bin));

%SINAD2=10*log10(Ps/(Phn));

%ENOB2=(SINAD2-1.76)/6.02;

%fprintf('SINAD2=%gdB n',SINAD2);

%fprintf('ENOB2=%g n',ENOB2);

%disp('Calculation above is anther way to get SINAD and ENOB');

format;

A=(max(DOUT_sum_uni)-min(DOUT_sum_uni));

AdB=20*log10(A);

%SINAD=10*log10(Ps/(Pn+Pd));

%SNR=10*log10(Ps/Pn);

SINAD=10*log10(Ps/(Pn+Pd));

SNR=10*log10(Ps/(Pn));

disp('THD is calculated from 2nd through 5th order harmonics');

THD=10*log10(Pd/Ph(1));

SFDR=10*log10(Ph(1)/max(Ph(2:10)));

disp('Signal & Harmonic power components:');

HD=10*log10(Ph(1:10)/Ph(1));

ENOB =(SINAD-1.76)/6.0206;

%distinguish all harmonics locations within the FFT plot

hold on;

plot(Fh(2)*fs,0,'mo',Fh(3)*fs,0,'cx',Fh(4)*fs,0,'r+',Fh(5)*fs,0,'g*',Fh(6)*fs,0,'bs',Fh(7)*fs,0,'bd',Fh(8)*fs,0,'kv',Fh(9)*fs,0,'y^');

legend('1st','2nd','3rd','4th','5th','6th','7th','8th','9th');

fprintf('SINAD=%gdB n',SINAD);

fprintf('SNR=%gdB n',SNR);

fprintf('THD=%gdB n',THD);

fprintf('SFDR=%gdB n',SFDR);

fprintf('ENOB=%g n',ENOB);

报错信息为:

??? Subscript indices must either be real positive integers or logicals.

Error in ==> fft at 59

Ps=sum(spectP(fin-span:fin+span));

能出图,但数据计算不了。。。求教!求教!

最后

以上就是苗条电话为你收集整理的fft频谱 matlab,matlab流水线ADC仿真FFT频谱测试【求高手搭救】的全部内容,希望文章能够帮你解决fft频谱 matlab,matlab流水线ADC仿真FFT频谱测试【求高手搭救】所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(40)

评论列表共有 0 条评论

立即
投稿
返回
顶部