This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Adaptive Noise Cancellation Using ANFIS

This example shows how to do adaptive nonlinear noise cancellation using the anfis and genfis commands.

Signal and Noise

Define a hypothetical information signal, x, sampled at 100Hz over 6 seconds.

time = (0:0.01:6)';
x = sin(40./(time+0.01));
title('Information Signal x','fontsize',10)

Assume that x cannot be measured without an interference signal, , which is generated from another noise source, , via a certain unknown nonlinear process.

The plot below shows noise source .

n1 = randn(size(time));
title('Noise Source n_1','fontsize',10)

Assume that the interference signal, , that appears in the measured signal is generated via an unknown nonlinear equation:

Plot this nonlinear characteristic as a surface.

domain = linspace(min(n1),max(n1),20);
[xx,yy] = meshgrid(domain,domain);
zz = 4*sin(xx).*yy./(1+yy.^2);

title('Unknown Interference Channel Characteristics','fontsize',10);

Compute the interferenace signal, , from the noise source, , and plot both signals.

n1d0 = n1;                            % n1 with delay 0
n1d1 = [0; n1d0(1:length(n1d0)-1)];   % n1 with delay 1
n2 = 4*sin(n1d0).*n1d1./(1+n1d1.^2);  % interference

ylabel('noise n_1','fontsize',10);
ylabel('interference n_2','fontsize',10);

is related to via the highly nonlinear process shown previously; from the plots, it is hard to see if these two signals are correlated in any way.

The measured signal, m, is the sum of the original information signal, x, and the interference, . However, we do not know . The only signals available to us are the noise signal, , and the measured signal m.

m = x + n2;             % measured signal
plot(time, m)
title('Measured Signal','fontsize',10)

You can recover the original information signal, x, using adaptive noise cancellation via ANFIS training.

Build the ANFIS Model

Use the anfis command to identify the nonlinear relationship between and . While is not directly available, you can assume that m is a "contaminated" version of for training. This assumption treats x as "noise" in this kind of nonlinear fitting.

Assume the order of the nonlinear channel is known (in this case, 2), so you can use a 2-input ANFIS structure for training.

Define the training data. The first two columns of data are the inputs to the ANFIS structure, and a delayed version of . The final column of data is the measured signal, m.

delayed_n1 = [0; n1(1:length(n1)-1)];
data = [delayed_n1 n1 m];

Generate the initial FIS structure. By default, the grid partitioning algorithm uses two membership functions for each input variable, which produces four fuzzy rules for learning.

genOpt = genfisOptions('GridPartition');
inFIS = genfis(data(:,1:end-1),data(:,end),genOpt);

Tune the FIS using the anfis command with an initial training step size of 0.2.

trainOpt = anfisOptions('InitialFIS',inFIS,'InitialStepSize',0.2);
outFIS = anfis(data,trainOpt);
ANFIS info: 
	Number of nodes: 21
	Number of linear parameters: 12
	Number of nonlinear parameters: 12
	Total number of parameters: 24
	Number of training data pairs: 601
	Number of checking data pairs: 0
	Number of fuzzy rules: 4

Start training ANFIS ...

   1 	 0.761817
   2 	 0.748426
   3 	 0.739315
   4 	 0.733993
   5 	 0.729492
Step size increases to 0.220000 after epoch 5.
   6 	 0.725382
   7 	 0.721269
   8 	 0.717621
   9 	 0.714474
Step size increases to 0.242000 after epoch 9.
  10 	 0.71207

Designated epoch number reached --> ANFIS training completed at epoch 10.

Minimal training RMSE = 0.712070

The tuned FIS, outFIS, models the second-order relationship between and .

Evaluate Model

Calculate the estimated interference signal, estimated_n2, by evaulating the tuned FIS using the original training data.

estimated_n2 = evalfis(data(:,1:2),outFIS);

Plot the and actual signal and the estimated version from the ANFIS output.

plot(time, n2)
ylabel('n_2 (unknown)'); 

plot(time, estimated_n2)
ylabel('Estimated n_2');

The estimated information signal is equal to the difference between the measured signal, m, and the estimated interference (ANFIS output).

estimated_x = m - estimated_n2;

Compare the original information signal, x, and the estimate, estimated_x.

legend('Estimated x','Actual x (unknown)','Location','SouthEast')

Without extensive training, the ANFIS produces a good estimate of the information signal.

Was this topic helpful?