-
Notifications
You must be signed in to change notification settings - Fork 1
/
CRC_burst_checksum.m
66 lines (41 loc) · 1.37 KB
/
CRC_burst_checksum.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
54
55
56
57
58
59
60
61
62
63
64
65
66
%% CRC_Checksum_burst_noise
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all
close all
clc
%% To Generate New Data
% bit_length = 8;
% T = im2bits(imread('cameraman.tif'),bit_length);
% save T
% LOADING GENERATED DATA
load('T.mat','T'); % T.bits contains columns of binary bits
%% Appending a 8bit Checksum for every 16 bits
% To add checksum as a new column in T_image.bits
[T.pbits, S] = checksum_add(T.bits);
%% Adding awgn noise to data
noise_sigma_max = 0.35;
samples = 100;
sigma = linspace(0,noise_sigma_max,samples);
for i=1:size(sigma,2)
% Adding Noise for given sigma
[R(i).pbits] = burst_add(T.pbits, sigma(i));
% Find Bit Errors
Err(i) = find_errors_crc(T.pbits,R(i).pbits);
BER_actual(i) = Err(i).BER_CRC;
[summed, t_error, BER_crc ] = checksum_check(R(i).pbits);
BER_detected(i) = BER_crc;
disp(i);
end
%% PLOT AND LABELS
figure(1)
plot(sigma,BER_actual,'b','LineWidth',2);
hold on
plot(sigma,BER_detected,'g','LineWidth',2);
title('\bf CRC-CHECKSUM : BURST NOISE VARIANCE VS BER','FontSize',18);
xlabel('\bf Noise Standard deviation ( \sigma )','FontSize',16);
ylabel('\bf BER-symbols(16bits) ','FontSize',16);
h = legend('Actual BER','CRC Detected BER',...
'Location','NorthWest');
set(h,'FontSize',16);
hold off
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%