adc信噪比matlab测试代码,ADC测试matlab代码
前面有做過ADC性能測試,測試方式是先使用ADC采集一個單頻信號,然后利用matlab進行性能分析。
下面把matlab分析的代碼記錄下來:
%The following program code plots the FFT spectrum of a desired test tone. Test tone based on coherent sampling criteria, and
%computes SNR, SINAD, THD and SFDR.
%This program is believed to be accurate and reliable. This program may get altered without prior notification.;
%fid=fopen('F:\pelican_ADC_test\vjtag_prj\data_analysis\single_tone.txt','r');
%numpt=input('Number of Points in FFT? ');
%fclk=input('Sampling Frequency (MHz)? ');
%numbit=input('ADC Resolution (bits)? ');
close all;
clear all;
numpt=;
fclk=/;
% fclk=//;
numbit=;
% a=textread('dds_data_out.txt','%s')';%以字符形式打開文件
% a=dlmread('sample_data.txt','%s')';%以字符形式打開文件
a=dlmread('sample_data.txt','%s')';%以字符形式打開文件
v1=a'; %16進制轉化為10進制數,存儲進v1矩陣
% for i = :numpt
% v1(i) = bitxor(v1(i),);
% end
%v1 is a column vector(:numpt), and count is its length
%v1=dlmread('F:\pelican_ADC_test\vjtag_prj\data_analysis\single_tone.txt','');
%fclose(fid);
%change v1 into a row vector
code=v1';
%Warning: ADC output may be clipping - reduce input amplitude
if (max(code)==2^numbit-1) | (min(code)==0)
disp('WARNING: ADC OUTPUT MAYBE CLIPPING - CHECK INPUT AMPLITUDE!');
end
figure;
plot(code);
title('TIME DOMAIN')
xlabel('SAMPLES');
ylabel('DIGITAL OUTPUT CODE');
Dout=code-(2^numbit-1)/2; %Re-center the digitized sinusoidal input
Voltage=Dout./((2^numbit-1)/2)*(0.5);
figure;
plot([1:numpt],Voltage);
Doutw=(Dout').*blackmanharris(numpt); %add Minimum -term Blackman-Harris window
Dout_spect=fft(Doutw);
Dout_dB=*log10(abs(Dout_spect));
figure;
maxdB=max(Dout_dB(:numpt/)); %numpt points FFT result in numpt/ points spectrum
%計算距離滿量程的幅度差
max_voltage=max(Voltage);
delta_amplitude=*log10(max_voltage/0.5); %full scale voltage amplitude is .5v
plot([:numpt/-].*fclk/numpt,Dout_dB(:numpt/)-maxdB+delta_amplitude);
grid on;
title('SINGLE TONE FFT PLOT');
xlabel('ANALOG INPUT FREQUENCY (MHz)');
ylabel('AMPLITUDE (dBfs)');
a1=axis; axis([a1() a1() - a1()]);
fin=find(Dout_dB(:numpt/)==maxdB); %Find the signal bin (DC represents bin=)
DC_span=; %default DC leakage bins are bins
signal_span = ; %signal leakage bins are ± bins for minumun -term black-harris window
spanh=; %%default harmonic leakage bins are ± bins
spectP=(abs(Dout_spect)).*(abs(Dout_spect));
%Determine power level
Pdc=sum(spectP(:DC_span)); %Determine DC offset power level
Ps=sum(spectP(fin-signal_span:fin+signal_span)); %Determine signal power level
Fh=[];
%Vector storing frequency and power components of signal and harmonics
Ph=[]; %HD1=signal, HD2=2nd harmonic, HD3=3rd harmonic, etc.
%Find the harmonic frequencies/power within the FFT plot
for har_num=:
tone=rem((har_num*(fin- )+)/numpt,); %Note: tones > fSAMPLE are aliased back
if tone>0.5
tone=-tone;
end
Fh=[Fh tone];
%For this method to work properly, make sure that the folded back high order harmonics do not overlap with DC and signal
%components or lower order harmonics.
har_peak=max(spectP(round(tone*numpt)-spanh:round(tone*numpt)+spanh));
har_bin=find(spectP(round(tone*numpt)-spanh:round(tone*numpt)+spanh)==har_peak);
har_bin=har_bin+round(tone*numpt)-spanh- ; %make sure that the folded back high order harmonics do not overlap with DC and signal components or lower order harmonics
Ph=[Ph sum(spectP(har_bin-:har_bin+))];
end
Pd=sum(Ph(:)); %Total distortion power level
Pn=sum(spectP(:numpt/))-Pdc-Ps-Pd; %Extract noise power level
format;
A=(max(code)-min(code))/(^numbit) %Analog input amplitude in mV
AdB=*log10(A) %Analog input amplitude in dB
SNR=*log10(Ps/Pn) %SNR in dB
SINAD=*log10(Ps/(Pn+Pd)) %SINAD in dB
disp('THD - HD2 through HD9');
THD=*log10(Pd/Ph()) %THD in dB
SFDR=*log10(Ph()/max(Ph(:))) %SFDR in dB
disp('SIGNAL AND HARMONIC POWER (dB)');
HD=*log10(Ph(:)/Ph())
hold on;
plot(Fh()*fclk,-,'bo',Fh()*fclk,-,'bx',Fh()*fclk,-,'b+',Fh()*fclk,-,'b*',Fh()*fclk,-,'bs',Fh()*fclk,-,'bd',Fh()*fclk,-,'bv',Fh()*fclk,-,'b^');
legend('SIGNAL','HD2','HD3','HD4','HD5','HD6','HD7','HD8','HD9');
hold off;
輸出結果
A =
0.5432
AdB =
-5.3006
SNR =
54.0005
SINAD =
53.4240
THD - HD2 through HD9
THD =
-62.4784
SFDR =
63.0618
SIGNAL AND HARMONIC POWER (dB)
HD =
-63.0618 -78.1190 -79.6691 -82.4058 -86.1153 -90.7795 -91.1868 -89.8460 -74.6853
會標記出諧波的位置。
如何加速MATLAB代碼運行
學習筆記 V1.0 2015/4/17 如何加速MATLAB代碼運行 概述 本文源于LDPCC的MATLAB代碼,即.由于代碼的問題,在信息位長度很長 ...
SVM實例及Matlab代碼
******************************************************** ***數據集下載地址 :http://pan.baidu.com/s/1geb8CQf ...
測試C++代碼與WebBrowser HTML的互動
testWebBrowserDlg.h // testWebBrowserDlg.h : 頭文件 // #pragma once #include "explorer1.h" #i ...
多分類問題中,實現不同分類區域顏色填充的MATLAB代碼(demo:Random Forest)
之前建立了一個SVM-based Ordinal regression模型,一種特殊的多分類模型,就想通過可視化的方式展示模型分類的效果,對各個分類區域用不同顏色表示.可是,也看了很多代碼,但基本都是 ...
卷積相關公式的matlab代碼
取半徑=3 用matlab代碼實現上式公式: length=3;for Ki = 1:length for Kj = 1:length for Kk = 1:length Ksigma(Ki,Kj,K ...
使用JUnit測試java代碼
Junit 單元測試實驗報告 ?一.實驗環境 MyEclipse2014.Junit4.10 二.實驗目的 學會單元測試,在MyEclipse中進行Junit測試 三.實驗步驟 1.寫出要測試的類 代 ...
JAVA調用matlab代碼
做實驗一直用的matlab代碼,需要嵌入到java項目中,matlab代碼拼拼湊湊不是很了解,投機取巧采用java調用matlab的方式解決. 1. ? ?matlab版本:matlabR2014a ...
前端測試框架Jest系列教程 -- Asynchronous(測試異步代碼)
寫在前面: 在JavaScript代碼中,異步運行是很常見的.當你有異步運行的代碼時,Jest需要知道它測試的代碼何時完成,然后才能繼續進行另一個測試.Jest提供了幾種方法來處理這個問題. 測試異步 ...
調試和運行matlab代碼(源程序)的技巧和教程
轉載請標明出處:專注matlab代碼下載的網站http://www.downma.com/ 本文主要給大家分享使用matlab編寫代碼,完成課程設計.畢業設計或者研究項目時,matlab調試程序的技巧 ...
隨機推薦
調試關于Hibernate的程序遇到的問題
最怕的就是初學一些東西,低級的錯誤犯了又犯,現在總結出來以便以后不要再犯類似的錯誤. 一.Hibernate的延遲加載機制 在用hibernate底層訪問數據庫的過程忽略了延遲加載機制導致 在訪問時候 ...
Centos6.5更新e1000網卡驅動
導讀 在工作過程中經常遇到linux的操作系統網絡不正常的情況,以前沒有注意到,今天查看系統日志發現原來是網絡驅動的問題.索性直接更新系統,更新網卡 問題:linux系統經常出現斷網的情況,重啟之后系 ...
查看Linux硬件配置信息
在網上找了N久,發現了一篇不錯的文檔,轉載一下: 1.查看機器所有硬件信息: dmidecode |more dmesg |more 這2個命令出來的信息都非常多,所以建議后面使用"|mor ...
Android中Universal Image Loader開源框架的簡單使用
UIL (Universal Image Loader)aims to provide a powerful, flexible and highly customizable instrument ...
pollard_rho和Miller_Rabin
Miller_Rabin就是以概論大小來判斷素數 可以判斷2^63范圍的數 pollard_rho推薦兩個很好的博客來理解:整數分解費馬方法以及Pollard?rho和[ZZ]Pollard Rho算 ...
php正則表達式總結
<?php echo 'wj'; echo '
'; $file = '
總結
以上是生活随笔為你收集整理的adc信噪比matlab测试代码,ADC测试matlab代码的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 计算机表格最高分,excel表格里怎样算
- 下一篇: matlab plot颜色