Need Matlab code for finding SNR via Hspice output

Status
Not open for further replies.

Snik

Newbie level 4
Joined
Apr 19, 2009
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,337
SNR

Hi dear all friends,
i wanna design track and hold for 13bit ADC, but i don't know how test this T/H and calculate SNR of this block. i would be appreciated if anybody give me Matlab code for finding SNR(via Hspice output that printed in .Lis file).
Thx
 

N = 2048;
cycles = 67;
fs = 1000;
fx = fs*cycles/N;
LSB = 2/2^10;
%generate signal, quantize and take FFT
x = cos(2*pi*fx/fs*[0:N-1]);
x = round(x/LSB)*LSB;
s = abs(fft(x));
s = s(1:end/2)/N*2;
% calculate SNR
f = [0:N/2-1]/N;
sigbin = 1 + cycles;
noise = [s(1:sigbin-1), s(sigbin+1:end)];
snr =10*log10( s(sigbin)^2/sum(noise.^2) );
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…