-
Notifications
You must be signed in to change notification settings - Fork 0
/
Part2.m
129 lines (83 loc) · 4.43 KB
/
Part2.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
SNR = (1:1:25); %Range of SNR values
count = 10; %Iterations per SNR value for more accurate result
% Error Rate Vs SNR for [OOK, BPSK, M-Ary(2 bit), BFSK]
figure();
finalErrorRate = SNRTraverse (SNR, count, 'Part2_OOK');
semilogy(SNR, max(10^(-5),finalErrorRate));
title( {'Error Rate Vs SNR';'\fontsize{8}[OOK, BPSK, M-ARY ASK(2 bit), M-ARY PSK(2 bit), BFSK]'},'fontsize',10)
xlabel('SNR')
ylabel('Error Rate')
hold on;
finalErrorRate = SNRTraverse (SNR, count, 'Part2_BPSK');
semilogy(SNR, max(10^(-5),finalErrorRate));
finalErrorRate = SNRTraverse (SNR, count, 'Part2_MaryASK');
semilogy(SNR, max(10^(-5),finalErrorRate));
finalErrorRate = SNRTraverse (SNR, count, 'Part2_MaryPSK');
semilogy(SNR, max(10^(-5),finalErrorRate));
finalErrorRate = SNRTraverse (SNR, count, 'Part2_BFSK');
semilogy(SNR, max(10^(-5),finalErrorRate));
legend({'OOK','BPSK','M-Ary ASK','M-Ary PSK','BFSK'},'Location','southwest')
disp("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
%SNR = (0.5:0.5:50);
% Error Rate Vs SNR for M-Ary ASK [2 bit, 3 bit, 4 bit, 5 bit] encoding
figure();
finalErrorRate = SNRTraverse (SNR, count, 'Part2_MaryASK', 2, "# of bits", 1,"Amplitude", 0.5, "Offset");
semilogy(SNR, max(10^(-5),finalErrorRate));
title({'Error Rate Vs SNR';'\fontsize{8} M-ARY ASK [2 bit, 3 bit, 4 bit, 5 bit] encoding'})
xlabel('SNR')
ylabel('Error Rate')
hold on;
finalErrorRate = SNRTraverse (SNR, count, 'Part2_MaryASK' , 3, "# of bits", 1,"Amplitude", 0.5, "Offset");
semilogy(SNR, max(10^(-5),finalErrorRate));
finalErrorRate = SNRTraverse (SNR, count, 'Part2_MaryASK' , 4, "# of bits", 1,"Amplitude", 0.5, "Offset");
semilogy(SNR, max(10^(-5),finalErrorRate));
finalErrorRate = SNRTraverse (SNR, count, 'Part2_MaryASK' , 5, "# of bits", 1,"Amplitude", 0.5, "Offset");
semilogy(SNR, max(10^(-5),finalErrorRate));
legend({'2 bit', '3 bit', '4 bit', '5 bit'},'Location','southwest')
disp("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
% Error Rate Vs SNR for M-Ary ASK amplitudes [1, 2, 10, 100] encoding
figure();
finalErrorRate = SNRTraverse (SNR, count, 'Part2_MaryASK', 2, "# of bits", 1,"Amplitude", 0.5, "Offset");
semilogy(SNR, max(10^(-5),finalErrorRate));
title({'Error Rate Vs SNR';'\fontsize{8} M-ARY ASK amplitudes [1, 2, 5, 10] encoding'})
xlabel('SNR')
ylabel('Error Rate')
hold on;
finalErrorRate = SNRTraverse (SNR, count, 'Part2_MaryASK' , 2, "# of bits", 2,"Amplitude", 0.5, "Offset");
semilogy(SNR, max(10^(-5),finalErrorRate));
finalErrorRate = SNRTraverse (SNR, count, 'Part2_MaryASK' , 2, "# of bits", 5,"Amplitude", 0.5, "Offset");
semilogy(SNR, max(10^(-5),finalErrorRate));
finalErrorRate = SNRTraverse (SNR, count, 'Part2_MaryASK' , 2, "# of bits", 10,"Amplitude", 0.5, "Offset");
semilogy(SNR, max(10^(-5),finalErrorRate));
legend({'1', '2', '5', '10'},'Location','southwest')
disp("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
% Error Rate Vs SNR for M-Ary ASK threshold [0.25, 0.5, 0.75] encoding
figure();
finalErrorRate = SNRTraverse (SNR, count, 'Part2_MaryASK', 2, "# of bits", 1,"Amplitude", 0.25, "Offset");
semilogy(SNR, max(10^(-5),finalErrorRate));
title({'Error Rate Vs SNR';'\fontsize{8} M-ARY ASK threshold [0.25, 0.5, 0.75] encoding'})
xlabel('SNR')
ylabel('Error Rate')
hold on;
finalErrorRate = SNRTraverse (SNR, count, 'Part2_MaryASK' , 2, "# of bits", 1,"Amplitude", 0.5, "Offset");
semilogy(SNR, max(10^(-5),finalErrorRate));
finalErrorRate = SNRTraverse (SNR, count, 'Part2_MaryASK' , 2, "# of bits", 1,"Amplitude", 0.75, "Offset");
semilogy(SNR, max(10^(-5),finalErrorRate));
legend({'0.25', '0.5', '0.75'},'Location','southwest')
disp("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
% Error Rate Vs SNR for M-Ary PSK [2 bit, 3 bit, 4 bit, 5 bit] encoding
figure();
finalErrorRate = SNRTraverse (SNR, count, 'Part2_MaryPSK', 2, "# of bits");
semilogy(SNR, max(10^(-5),finalErrorRate));
title({'Error Rate Vs SNR';'\fontsize{8} M-ARY PSK [2 bit, 3 bit, 4 bit, 5 bit] encoding'})
xlabel('SNR')
ylabel('Error Rate')
hold on;
finalErrorRate = SNRTraverse (SNR, count, 'Part2_MaryPSK' , 3, "# of bits");
semilogy(SNR, max(10^(-5),finalErrorRate));
finalErrorRate = SNRTraverse (SNR, count, 'Part2_MaryPSK' , 4, "# of bits");
semilogy(SNR, max(10^(-5),finalErrorRate));
finalErrorRate = SNRTraverse (SNR, count, 'Part2_MaryPSK' , 5, "# of bits");
semilogy(SNR, max(10^(-5),finalErrorRate));
legend({'2 bit', '3 bit', '4 bit', '5 bit'},'Location','southwest')
disp("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")