-
Notifications
You must be signed in to change notification settings - Fork 4
/
shannon.m
53 lines (40 loc) · 1 KB
/
shannon.m
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
% shannon.m
%author:Cedric Marchand Lab-STICC
%
%Shannon limit for Gaussian channel
% Capacity of unconstrained Gaussian channel
% Shannon-Hartly equation: C=B log2(1+S/N)
% C/B=r spectral efficienty in bit/second/hz
clear;
%%
% compute SNR bound for a given modulation and code rate
CR=1/2; % code rate
mod=2; %modulation, bits per synbol
r=CR*mod;
SNR=2^r-1;
Ebno=SNR/r;
SNR_dB=10*log(SNR);
Ebno_db=10*log(Ebno);
%%
% spectral efficincy vs SNR
SNR_dB=-5:0.5:30;
SNR = 10.^(SNR_dB./10);
r=log2(1+SNR);
figure(1);
plot(SNR_dB,r);
grid on;
xlabel('Signal to Noise Ratio, SNR(dB)');
ylabel('Spectral efficiency, R/W bit/sec/Hz');
title('Spectral efficiency vs SNR');
%%
% spectral efficiency vs EbNo
figure(2);
r = 0:.001:10;
Eb_No = (2.^r -1)./r;
Eb_No_dB = 10*log10(Eb_No);
plot(Eb_No_dB,r);
axis([-2 20 0.1 10]);
grid on;
xlabel('Bit to noise ratio, Eb/No(dB)');
ylabel('Spectral efficiency, R/W bit/sec/Hz');
title('Spectral efficiency vs Bit to Noise ratio');