DAC SNR Matlab 仿真 help?
录入:edatop.com 阅读:
那位帮忙解释一下以下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?
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?
simpower system
申明:网友回复良莠不齐,仅供参考。如需专业解答,请学习本站推出的微波射频专业培训课程。
上一篇:请教关于LDO的负载调整率问题
下一篇:问一个关于PLL的问题,望高手解答!