K. J.
Somaiya College of Engineering, Mumbai-77
(Autonomous College Affiliated to University of Mumbai)
Department of Electronics Engineering
Batch No. A4 Roll No. 1622018
Experiment / assignment / tutorial No. 6
Grade: AA / AB / BB / BC / CC / CD /DD
Signature of the Faculty In-charge with date
Title: Adaptive Filters.
______________________________________________________________________
Aim and Objective of the Experiment:
Construct an LMS adaptive filter object and use it to identify an unknown system. For
this example, use 500 iteration of the adapting process to determine the unknown filter
coefficients. Using the LMS algorithm, represents one of the most straightforward
technique for adaptive filters.
____________________________________________________________________
COs to be achieved:
CO3: Design and analysis of digital IIR/FIR filters for real time signals.
Apparatus / Software tools used: MATLAB
Theory:
Adaptive Filter
An adaptive filter is a computational device that attempts to model the relationship
between two signals in real time in an iterative manner. Adaptive filters are often realized
either as a set of program instructions running on an arithmetical processing device such
as a microprocessor or DSP chip, or as a set of logic operations implemented in a field-
programmable gate array (FPGA) or in a semicustom or custom VLSI integrated circuit.
However, ignoring any errors introduced by numerical precision effects in these
implementations, the fundamental operation of an adaptive filter can be characterized
independently of the specific physical realization that it takes.
An adaptive filter is defined by four aspects:
1
Department of Electronics Engineering
SPL_July-Nov: 2018-19
K. J. Somaiya College of Engineering, Mumbai-77
(Autonomous College Affiliated to University of Mumbai)
Department of Electronics Engineering
1. The signals being processed by the filter
2. The structure that defines how the output signal of the filter is computed from its
input signal
3. The parameters within this structure that can be iteratively changed to alter the
filter’s input-output relationship
4. The adaptive algorithm that describes how the parameters are adjusted from one time
instant to the next
______________________________________________________________________
Stepwise-Procedure / Algorithm:
Click on the MATLAB Icon on the desktop.
2. MATLAB window open.
3. Click on the ‘FILE’ Menu on menu bar.
4. Click on NEW M-File from the file Menu.
5. An editor window open, start typing commands.
6. Now SAVE the file in directory.
7. Then Click on DEBUG from Menu bar and Click Run
CODE:
2
Department of Electronics Engineering
SPL_July-Nov: 2018-19
K. J. Somaiya College of Engineering, Mumbai-77
(Autonomous College Affiliated to University of Mumbai)
Department of Electronics Engineering
Fs = 1000; % Sampling frequency
T = 1/Fs; % Sampling period
L = 1500; % Length of signal
t = (0:L-1)*T; % Time vector
FrameSize = 100; % Frame size for LMS Filter
NIter = 10; % No of iterations
% Generate Sine Wave Object
sinewave = dsp.SineWave('Frequency',50, ...
'SampleRate',Fs,'SamplesPerFrame',FrameSize);
% Define Time Scope
TS = dsp.TimeScope('TimeSpan',FrameSize*NIter,'TimeUnits','Seconds',...
'YLimits',[-3 3],'BufferLength',2*FrameSize*NIter, ...
'ShowLegend',true,'ChannelNames', ...
{'Output signal', 'Error signal'});
% LP IIR Filter (Butterworth): START
lpFilt0 = designfilt('lowpassiir', 'PassbandFrequency', 100, ...
'StopbandFrequency', 150, 'PassbandRipple', 0.2, ...
'StopbandAttenuation', 60, 'SampleRate', 1000, ...
'DesignMethod', 'butter');
% LP IIR Filter (Butterworth): END
% Adaptive Filter Implementation: START
lms = dsp.LMSFilter('Length',11,'Method','Normalized LMS', ...
'StepSize',0.05);
for k = 1:NIter
IP_Noise = randn(FrameSize,1);
DesiredSignal = filter(lpFilt0, IP_Noise) + sinewave();
[OutputSignal,e,w] = lms(IP_Noise, DesiredSignal);
TS([OutputSignal, e])
end
release(TS)
% Adaptive Filter Implementation: END
OUTPUT:
Department of Electronics Engineering
SPL_July-Nov: 2018-19
K. J. Somaiya College of Engineering, Mumbai-77
(Autonomous College Affiliated to University of Mumbai)
Department of Electronics Engineering
Post Lab Subjective / Objective type Questions:
4
Department of Electronics Engineering
SPL_July-Nov: 2018-19
K. J. Somaiya College of Engineering, Mumbai-77
(Autonomous College Affiliated to University of Mumbai)
Department of Electronics Engineering
1. What is significance of adaptive filter
An adaptive filter is a system with a linear filter that has a transfer function controlled by
variable parameters and a means to adjust those parameters according to an optimization
algorithm. Because of the complexity of the optimization algorithms, almost all adaptive
filters are digital filters. Adaptive filters are required for some applications because some
parameters of the desired processing operation (for instance, the locations of reflective
surfaces in a reverberant space) are not known in advance or are changing. The closed loop
adaptive filter uses feedback in the form of an error signal to refine its transfer function.
Example: The recording of a heart beat (an ECG), may be corrupted by noise from the AC
mains. The exact frequency of the power and its harmonics may vary from moment to
moment.
One way to remove the noise is to filter the signal with a notch filter at the mains frequency
and its vicinity, which could excessively degrade the quality of the ECG since the heart beat
would also likely have frequency components in the rejected range.
To circumvent this potential loss of information, an adaptive filter could be used. The
adaptive filter would take input both from the patient and from the mains and would thus be
able to track the actual frequency of the noise as it fluctuates and subtract the noise from
the recording. Such an adaptive technique generally allows for a filter with a smaller rejection
range, which means, in this case, that the quality of the output signal is more accurate for
medical purposes
Conclusion: Thus we have studied and performed Adaptive Filter on MATLAB
Date: _____________ Signature of faculty in-charge with date
Department of Electronics Engineering
SPL_July-Nov: 2018-19