summaryrefslogtreecommitdiff
path: root/3446/CH4/EX4.2/Ex4_2.sce
blob: 9e51ee33e2120ab52cc97dc0f51e717646cef2ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Exa 4.2
// To calculate SNR for L=32, 64, 128, and 256.

clc;
clear all;

Rt=1; //Resistance(ohm)
//L= Number of quantization values
L1=32;
L2=64;
L3=128;
L4=256;

// solution
// L=2^R i.e R=log2(L);
R1=log2(L1);
R2=log2(L2);
R3=log2(L3);
R4=log2(L4);

//P=A^2/2; //average power of signal
//sig^2=0.333*A^2*2^(-2*Rt); //Avg quantization noise power
//SNR=P/sig^2;
// SNR(dB)=1.8+ 6R;

SNR1=1.8+6*R1;
SNR2=1.8+6*R2;
SNR3=1.8+6*R3;
SNR4=1.8+6*R4;

printf('For L=32, SNR is %.1f dB\n ',SNR1);
printf('For L=64, SNR is %.1f dB\n ',SNR2);
printf('For L=128, SNR is %.1f dB\n ',SNR3);
printf('For L=256, SNR is %.1f dB\n ',SNR4);