?? sga.m
字號:
function [coeff, coeff_hist, abs_err] = sga(Desire, Red, NE, delay,
beta)
%
% function [coeff, coeff_hist, abs_err] = sga(Desire, Red, NE, delay,
beta)
%
% implements the Stochastic Gradient Algorithm
% for computing equalizer coefficients
%
% inputs:
% Desire = known transmitted signal (training sequence)
% Red = received signal
% NE = equalizer length
% delay = equalizer delay
% beta = step size
%
% output:
% coeff = converged equalizer coefficients
% coeff_hist = history of convergence of coefficients
% abs_err = absolute error between transmitted
% signal and equalized signal
%
c = zeros(NE,length(Desire));
c0 = zeros(NE,1);
c0(delay+1) = 0.5;
A_hat = zeros(size(Desire));
% check dimension of Red; we want it to be a column
if size(Red, 2) > 1
Red = Red.';
end;
start = max(1, NE-delay);
len = min([length(Desire) - delay, length(Red) - delay]);
finish = len;
old_percent = -1;
%=================
for ix = start:finish
% update the impatient user in increments of 10%
new_percent = 10*fix(10*(ix-start)/(finish-start));
if new_percent ~= old_percent
disp([int2str(new_percent), '% done']);
old_percent = new_percent;
end;
Rk_window = Red((ix+delay):-1:(ix+delay-NE+1));
if ix ~= start
old_c = c(:,ix-1);
else % ix == start
old_c = c0;
end;
A_hat(ix) = Rk_window.'*old_c;
c(:,ix) = old_c + beta*conj(Rk_window)*(Desire(ix)-A_hat(ix));
end % for
%=================
% to get coefficients, take the mean of the last 20%
% of the samples to minimize the effects of noise
len = length(start:finish);
last_20_percent = (finish - fix(len/5)):finish;
coeff = mean(c(:,last_20_percent).').';
coeff_hist = c(:,start:finish);
abs_err = abs(Desire(start:finish)-A_hat(start:finish));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% end of function
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -