-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBER_Check.m
More file actions
32 lines (22 loc) · 870 Bytes
/
BER_Check.m
File metadata and controls
32 lines (22 loc) · 870 Bytes
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
%% Clear all workspace variables except for sdr objects
% List of variables to keep
varsToKeep = {'sdr0', 'sdr1', 't_hat_no_bfm', 't_hat_bfm_IC', 't_hat_bfm_NIC', 'input_bits', 'nFFT', 'scMin', 'scMax'};
% Get the list of all variables in the workspace
allVars = whos;
% Construct the command to clear all variables except those in varsToKeep
clearCommand = 'clear ';
for k = 1:length(allVars)
if ~ismember(allVars(k).name, varsToKeep)
clearCommand = [clearCommand allVars(k).name ' '];
end
end
% Execute the clear command
eval(clearCommand);
clear allVars clearCommand k
%% Choose the stream
t_hat_plot = squeeze(t_hat_bfm_NIC(:, 1));
%% BER
rx_symbols = t_hat_plot(nFFT/2 + 1 + scMin:nFFT/2 + scMax, 1);
[rx_bits, received_bits] = qpsk_demodulation(rx_symbols);
errors = sum(received_bits ~= input_bits.');
BER = errors / size(input_bits,1)