威望0
积分7946
贡献0
在线时间763 小时
UID1
注册时间2021-4-14
最后登录2024-11-21
管理员
- UID
- 1
- 威望
- 0
- 积分
- 7946
- 贡献
- 0
- 注册时间
- 2021-4-14
- 最后登录
- 2024-11-21
- 在线时间
- 763 小时
|
[mw_shl_code=applescript,true]%-------draft-----
clc,clear
% filename = 'SAR_ADC_DACoutput.csv'; %DAC输出数据
% table = csvread(filename,1,0);
table=xlsread('data.xlsx');
table;
x = table(:,1);
A = table;
B = size(A,2)-2;
c_min = min(A(:,B+2));
c_max = max(A(:,B+2));
nump = size(A(:,B+2));
N = 2^12;
%----------- set value ---------------
fs = 1;
Ts = 1/fs;
t = 0:TsN-1)*Ts;
noise_value = 100;
vout = [A(:,1) A(:,B+2)];
%------------SNR Calculation----------
vof = abs((fft(vout,N)))/N;
vof = vof/max(vof);
vof_db = db(vof);
vofh = vof(1:N/2);
[vs,is] = max(vofh(1:N/2));
Ps = vs^2;
Phar = norm(vofh(2:is-1))^2+norm(vofh(is+1:N/2))^2;
Pnoise = norm(vofh(find(db(vofh)<-noise_value)))^2;
SQNR = 10*log10(Ps/Pnoise)
SNDR = 10*log10(Ps/Phar)
NPWR = 10*log10(Phar);
freq = 0:fs/Nfs/2-fs/N);
figure, H = plot(freq*1e-3, vof_db(1:N/2), 'k-');
grid on;[/mw_shl_code] |
|