在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 10300|回复: 3

DAC SNR Matlab 仿真 help?

[复制链接]
发表于 2009-8-20 11:10:44 | 显示全部楼层 |阅读模式

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

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

x
那位帮忙解释一下以下Code的意义。

clear all;

N=2^12;                         % The input sequence is made by 2^12 points
Nbit=8;                         % 8-bit DAC
Ntransient=11;                 
Ntot=N+Ntransient;
nper=311;                       % prime integer number of sine waveforms
Fs=1;
bw=0.5;
Fin=nper*Fs/N;                  % Input signal frequency (Fin=nper*Fs/N)
Vref=0.5;                       % Full scale for an input sinewave
Amp_dB=-0;                      % Amplitude in dB
Ampl=10^(Amp_dB/20)*Vref;       % Input signal amplitude

finrad=Fin*2*pi;
alphadx=0.0001;                 % gradient in the resistivity
den=2^Nbit-1+alphadx*2^Nbit*(2^Nbit-1)/2;

for i=1:Ntot,
    x=Vref*sin(finrad*(i-1))+Vref;      % Unipolar range
    k=round(x*2^Nbit);
    vout=(k+alphadx*k*(k+1)/2)/den;
    y(i)=vout;
end

y=y-mean(y)                            % Output with zero average

%--------------------------------Graphics---------------------------------%

figure(1);
clf;
plot(y,'r');
grid;
xlim([1600 1900]);
title('Sinewave with distortion');

w=ones(1,N);
f=Fin/Fs;                               % Normalized signal frequency
fB=N*(bw/Fs);                           % Base-band frequency bins
[snr,ptot]=calcSNR(y(1:N),f,fB,w,N);
ptot=ptot-max(ptot);                    % Normalize total spectrum

figure(2);
clf;
plot(linspace(0,Fs/2,N/2), ptot(1:N/2), 'r');
grid on;
title('PSD of the Output')
xlabel('Frequency [Hz]')
ylabel('PSD [dB]')
axis([0 Fs/4 -120 0]);
text(Fs/10,-20,sprintf('\\bfSNR = %3.1fdB  @  \\alpha\\DeltaX = %1.0e\n'...
    ,snr,alphadx),'Fontsize',12);
text(f*2,ptot((f*N+1)*2-1)+3,sprintf('\\bf%2.1fdB',ptot((f*N+1)*2-1)),...
    'Fontsize',8,'HorizontalAlignment','center');

Ntransient表示什么意思?
Ntot=N+Ntransient表示什么意思?
Fin为什么为nper*Fs/N?
发表于 2011-3-17 14:23:30 | 显示全部楼层
simpower system
发表于 2019-9-29 16:40:09 | 显示全部楼层
Mark一下
发表于 2020-4-7 13:44:30 | 显示全部楼层
mark 一下
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /2 下一条

×

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-4-27 21:10 , Processed in 0.026222 second(s), 8 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表