% % For illustrative purposes this duplicates the MATLAB code on % epage 73 from the book but specified for the problem 4.3.2 on epage % % Written by: % -- % John L. Weatherwax 2008-11-24 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- addpath( '../../AdaptiveFilteringCode/' ); clear functions; clear; %clc; close all; drawnow; M = 2; N = 200; sigmaV2 = 0.15; % <- the variance of the noise v(n) v = sqrt(sigmaV2)*randn(1,N); x = randn(1,N); % <- input data sequance x(n) (zero mean, variance one) b = [ 0.9, 0.25 ]; % <- the unknown filter coeffients b = [ 1, 0.38 ]; sysout = filter( b, 1, x ); dn = sysout + v; rx = aasamplebiasedautoc(x,M); Rx = toeplitz(rx); % <- this should approximate the identity fprintf('Is Rx close to the identity matrix ... %d\n', norm( Rx-eye(M) ) < 1e-1 ); pdx = xcorr(x,dn,'biased'); p = pdx((N-(M-1)):N); p = fliplr(p); % <- this should approximate [ b0, b1 ] fprintf('Is p close to the vector b ... %d\n', norm( p(1:2) - b ) < 1e-1 ); %w = inv(Rx)*p.'; w = Rx\p(:); fprintf('Is w close to the vector b ... %d\n', norm( w(1:2).' - b ) < 1e-1 ); dnc = aasamplebiasedautoc(dn,1); jmin = dnc - p*w; fprintf('\n'); fprintf( 'the original filter coefficients were = \n'); disp(b); fprintf('the optimal filter values found are w = \n'); disp(w.'); fprintf( 'the minumum J value is = \n'); disp(jmin);