-
Notifications
You must be signed in to change notification settings - Fork 0
/
filter_tx.m
39 lines (28 loc) · 996 Bytes
/
filter_tx.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
function [s] = filter_tx(z, oversampling_factor, switch_graph, switch_off)
if switch_off == 0
z_upsampled = zeros(length(z) * oversampling_factor, 1);
z_upsampled(1: oversampling_factor : end) = z; % Upsampling by oversampling factor
tx_filter = sqrt(oversampling_factor) * rcosdesign(0.25,10,20);
s_filtered = conv(z_upsampled, tx_filter);
s = s_filtered / sqrt(mean(abs(s_filtered).^2)); % Signal power is normalized to 1
if switch_graph == 1
fvtool(tx_filter)
figure('Name', 'Transmitter Filter Output')
subplot(2,1,1)
plot(real(s),'g')
grid on
title('Tx Filter Output')
xlabel('Time')
ylabel('Amplitude')
legend ('Real')
subplot(2,1,2)
plot(imag(s),'r')
grid on
xlabel('Time')
ylabel('Amplitude')
legend ('Imaginary')
end
else
s = z;
end
end