📄 receiver_rls.m
字号:
%+----------------------------------------------------------------+
%| |
%| Name: receiver_rls.m |
%| Author: James Shen |
%| Description: Takes ina signal and tries to demodulate it. |
%| We assume that we are receiving pilot signals so that the |
%| desired signal is know already. What happens in a real |
%| implementation is that the weiner coefficients derived will |
%| continue to be used with data and the desired signal will |
%| then be the decovered signal. This will accumulate errors in |
%| the coefficients until the next batch of pilot symbols |
%| arrive. Receives one OFDM. |
%| |
%+----------------------------------------------------------------+
function[recovered_signal,w,e] = ...
receiver_rls(desired_signal, noisy_signal, FFTLen, CPLen, M, w, F);
% desired_signal The signal you want to obtain after filtering.
% noisy_signal This signal is somehow correlated to the desired_signal.
% FFTLen This is the size of the FFT to be used. Should be a power of
% 2. Hyoerlan works to 64 points.
% M Bits per symbol used in baseband mod and demod.
% w The filter coefficients
% F Samples taken for correlation and that of the Kalman filter.
% e Error (desired_signal - noisy_signal)
% recovered _signal = the signal that is finally output.
%+----------------------------------------------------------------+
%| OFDM RECEVIER |
%+----------------------------------------------------------------+
%======================= RLS Equalizer ================================
%======================= Initializations ================================
N = length(desired_signal);
P = zeros(F,1); % Inverse correlation matrix.
P = eye(F)*100;
udata = noisy_signal; % Noisy signal yet correlated to desired.
d = desired_signal; % Desired signal.
lambda = 0.9; % Weighting factor 0.95<=w<=1
%====================== Filter Iterations ==============================
for n=F:N
u = flipud(udata(n:-1:(n-F+1)).'); %col vector now
K = P*u ./ ((1-lambda) + u.'*P*u);
y(n) = w.'*u;
e(n) = d(n) - y(n);
w = w + K*e(n);
P = (1/(1-lambda))*(eye(F) - K*u.')*P;
end
output_ext = y; % ext means still with cyclic prefix extension.
%============== Gaurd Interval Removal (GIR) ==================
output_time_serial = output_ext((CPLen+1):FFTLen+CPLen);
%======== Serial To Parallel =================================
output_time_para = reshape(output_time_serial,FFTLen,1);
%================= FFT =================================
output_symbols = fft(output_time_para);
%================= Baseband Demodulation ===========================
output_para = qamdemod(output_symbols,FFTLen, M);
%================ Parallel to Serial ====================
output = reshape(output_para,1,FFTLen*M); % Time domain signal
%================ Returning output ===============================
recovered_signal = output;
w = w;
e = e;
% The code below should be commented out when
% running for more than one iteration as it just
% shows graphs for one symbol
%================ Error Calculation ===========================
error1= desired_signal - output_ext;
figure(1);
semilogy(abs(error1));
%================ Graphs ===========================
figure(2);
semilogy(abs(desired_signal), 'b'); hold on;
semilogy(abs(noisy_signal), 'g');
semilogy(abs(output_ext), 'r'); hold off;
figure(3);
semilogy(abs(e));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -