⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sga.m

📁 里面囊括了基于matlab滤波器设计的各种.m文件
💻 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 + -