-
Notifications
You must be signed in to change notification settings - Fork 1
/
DSB_SC_SSP_Coherent_Detection.m
49 lines (40 loc) · 1.59 KB
/
DSB_SC_SSP_Coherent_Detection.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
function DSB_SC_SSP_Coherent_Detection(tx_msg,carrier,fc,fs,new_fs,phase_error,SNR,fignum,i,type)
t_end = length(tx_msg)./new_fs;
t = linspace(0,t_end, length(tx_msg));
% add noise
tx_msg_noisy = awgn(tx_msg,SNR);
% coherent (multiply msg with carrier)
tr_msg_coh = tx_msg_noisy.*carrier;
tr_msg_coh_FREQ = fftshift(fft(tr_msg_coh));
% freq domain plot (befor Ideal LBF)
N = length(tr_msg_coh);
fvec = linspace(-new_fs/2,new_fs/2,N);
figure(fignum+10)
subplot(3,1,i)
tr_msg_coh_FREQ_mgn = abs(tr_msg_coh_FREQ);
plot(fvec,tr_msg_coh_FREQ_mgn)
title(type+" RX-Coherent (SNR="+SNR+") msg in frequency domain (FC="+fc+")(Phase error="+phase_error+") (befor Ideal LBF)")
%------------- LBF ---------------%
N = length(tr_msg_coh);
n = N/new_fs;
right_band = round((new_fs/2-4000)*n);
left_band = (N-right_band+1);
tr_msg_coh_FREQ([1:right_band left_band:N]) = 0;
tr_msg_coh_LPF = real(ifft(ifftshift(tr_msg_coh_FREQ)));
%------------- LBF ---------------%
% As a result of multipling the received signal with carrier there will be high freq components
% at 2fc. So, we put the filter to remove them.
% freq domain plot (after Ideal LBF)
figure(fignum+20)
subplot(3,1,i)
tr_msg_coh_FREQ_mgn = abs(tr_msg_coh_FREQ);
plot(fvec,tr_msg_coh_FREQ_mgn)
title(type+" RX-Coherent (SNR="+SNR+") msg in frequency domain (FC="+fc+")(Phase error="+phase_error+") (after Ideal LBF)")
% time domain plot
figure(fignum)
subplot(3,1,i)
plot(t,tr_msg_coh_LPF)
title(type+" RX-Coherent (SNR="+SNR+") msg in time domain (FC="+fc+")(Phase error="+phase_error+")")
original_msg = resample(tr_msg_coh_LPF,fs,new_fs);
%sound(original_msg,fs)
%pause(10);