% % For illustrative purposes this duplicates the MATLAB code on % page XXX from the book but specified for the problem 4.4.2 on epage XXX % % 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; randn('seed',0); rand('seed',0); N = 2^10; n = 0:(N-1); % our desired signal d(n): % dn = (0.99.^n) .* sin( 0.1*n*pi + 0.2*pi ); %dn = sin( 0.1*n*pi + 0.2*pi ); % the random driving input noise ... used in creating the observed noises v_1(n) and v_2(n) % v = 0.1*randn(1,N); % the coefficients of the ARMA(1,1) models for v_1(n) and v_2(n) % a1 = 0.8; a2 = -0.95; % plot the pure signal d(n) with the noised signal d(n) + v_1(n) % fo=figure; hd=plot( n, dn, '-og', 'markersize', 6 ); hold on; % <- the pure signal d(n) M=2; % get the observed noised signal to plot i.e. xn % alpha_dum = 0.0; [yw,w,en,xn] = aaWNC_with_leaking_signal(dn,alpha_dum,a1,a2,v,M,N); hdn=plot( n, xn, '-xr' ); xlabel( 'n' ); ylabel( 'measured signal' ); title( 'the pure signal and the signal with noise' ); %axis( [0,256,-Inf,+Inf] ); axis tight; legend( [hd,hdn], { 'd(n)', 'd(n)+v_1(n)' }, 'location', 'north' ); saveas( gcf, '../../WriteUp/Graphics/Chapter4/prob_4_4_2_NC_fig_1.eps', 'epsc' ); %M = 16; M = 64; % compare our signal approxmation for various amounts of signal leakage: % alphaArray = [ 0.05, 0.1, 0.3, 0.6, 1.0 ]; alphas_to_save = [ 0.05, 0.3, 1.0 ]; for mi=1:length(alphaArray), thisALPHA = alphaArray(mi); [yw,w,en,xn] = aaWNC_with_leaking_signal(dn,thisALPHA,a1,a2,v,M,N); figure; plot( n, dn, '-og', 'markersize', 6 ); hold on; %(fh); plot( n, en, '-xk' ); xlabel( 'n' ); ylabel( 'approximate signal' ); title( ['alpha=',num2str(thisALPHA)] ); %axis( [0,256,-Inf,+Inf] ); axis tight; if( ismember( thisALPHA, alphas_to_save ) ) saveas( gcf, ['../../WriteUp/Graphics/Chapter4/prob_4_4_2_NC_a_',num2str(thisALPHA),'.eps'], 'epsc' ); end end