-
Notifications
You must be signed in to change notification settings - Fork 4
/
test_polyphase.m
61 lines (52 loc) · 1.58 KB
/
test_polyphase.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
close all;
default_config;
numbits = 2048*10;
input_bits = text_file_to_binary('tale_of_two_cities.txt');
input_bits = input_bits(1:numbits);
PN = 10;
bauds = [1/16 1/8 1/4 1/2].*F_S/4;
UP = length(bauds);
output_f_s = F_S/UP;
freqs = -F_S/2:output_f_s:F_S/2;
freqs = freqs(1:end-1) + output_f_s/2;
disp('Generating Test Signal');
disp('----------------------');
tx = gen_test_sig(input_bits, PN, bauds, freqs).*1E3;
figure;
plot_spectrum(tx, F_S);
t = 0:(1/F_S):((length(tx)-1)/F_S);
tx = tx.*exp(1i.*2*pi.*output_f_s/2.*t); %Perform frequency shift
figure;
plot_spectrum(tx, F_S);
fprintf('\n');
disp('Running Analysis Channelizer');
disp('----------------------------');
%channels = analysis_channelizer(tx, length(bauds));
channels = analysis_channelizer(tx, 4);
plot_channels(channels, F_S*ones(4, 1));
fprintf('\n');
disp('Demodulating Each Channel');
disp('-------------------------');
% Plot results
disp('Plotting results...')
for i=1:length(bauds)
fprintf('CHANNEL %d\n', i);
SAMPLES_PER_SYMBOL = output_f_s/bauds(i)*2;
recompute_configuration;
bits = MyReceiver(channels{i});
fname = sprintf('channel_%d.bits', i);
fprintf('Writing %s...\n', fname);
% Trim down to numbits, because we know anything after that is garbage
% in the higher baud rate signals
if length(bits) > numbits
bits = bits(1:numbits);
end
binary_to_text_file(bits, fname);
end
fprintf('\n');
disp('Running Synthesis Channelizer');
disp('-----------------------------');
reconstruction = synthesis_channelizer(channels);
figure;
plot_spectrum(reconstruction, F_S);
disp('Done.')