Accelerating the pace of engineering and science

# Documentation Center

• Trial Software

# msesim

Measured mean-squared error for adaptive filter

## Syntax

mse = msesim(ha,x,d)
[mse,meanw,w,tracek] = msesim(ha,x,d)
[mse,meanw,w,tracek] = msesim(ha,x,d,m)

## Description

mse = msesim(ha,x,d) returns the sequence of mean-square errors in column vector mse. The vector contains estimates of the mean-square error of the adaptive filter at each time instant during adaptation. The length of mse is equal to size(x,1). The columns of matrix x contain individual input signal sequences, and the columns of the matrix d contain corresponding desired response signal sequences.

[mse,meanw,w,tracek] = msesim(ha,x,d) calculates three parameters that correspond to the simulated behavior of the adaptive filter defined by ha:

• meanw — sequence of coefficient vector means. The columns of this matrix contain estimates of the mean values of the LMS adaptive filter coefficients at each time instant. The dimensions of meanw are (size(x,1))-by-(ha.length).

• w — estimate of the final values of the adaptive filter coefficients for the algorithm corresponding to ha.

• tracek — sequence of total coefficient error powers. This column vector contains estimates of the total coefficient error power of the LMS adaptive filter at each time instant. The length of tracek is equal to size(X,1).

[mse,meanw,w,tracek] = msesim(ha,x,d,m) specifies an optional input argument m that is the decimation factor for computing meanw, mse, and tracek. When m > 1, msepsim saves every mth predicted value of each of these sequences. When you omit the optional argument m, it defaults to one.

## Examples

Simulation of a 32-coefficient FIR filter using 25 trials, each trial having 2000 iterations of the adaptation process.

x = zeros(2000,25); d = x;          % Initialize variables
ha = fir1(31,0.5);                  % FIR system to be identified
x = filter(sqrt(0.75),[1 -0.5],sign(randn(size(x))));
n = 0.1*randn(size(x));             % Observation noise signal
d = filter(ha,1,x)+n;               % Desired signal
l = 32;                             % Filter length
mu = 0.008;                         % LMS Step size.
m  = 5;                             % Decimation factor for analysis
% and simulation results
[simmse,meanWsim,Wsim,traceKsim] = msesim(ha,x,d,m);
nn = m:m:size(x,1);
subplot(2,1,1);
plot(nn,meanWsim(:,12),'b',nn,meanWsim(:,13:15),'b');
PlotTitle ={'Average Coefficient Trajectories for';...
'W(12), W(13), W(14), and W(15)'};
title(PlotTitle);
xlabel('Time Index'); ylabel('Coefficient Value');
subplot(2,2,3);
semilogy(nn,simmse);
title('Mean-Square Error Performance'); axis([0 size(x,1) 0.001...
10]);
legend('Measured MSE');
xlabel('Time Index'); ylabel('Squared Error Value');
subplot(2,2,4);
semilogy(nn,traceKsim);
title('Sum-of-Squared Coefficient Errors'); axis([0 size(x,1)...
0.0001 1]);
xlabel('Time Index'); ylabel('Squared Error Value');

Calculating the mean squared error for an adaptive filter is one measure of the performance of the adapting algorithm. In this figure, you see a variety of measures of the filter, including the error values.