This action might not be possible to undo. Are you sure you want to continue?

Welcome to Scribd! Start your free trial and access books, documents and more.Find out more

No:1

Date:

GENERATION OF SIGNALS

AIM:

To write a Matlab program and generate the following discrete time

signals.

1. Unit step

2. Unit Impluse

3. Unit ramp

4. Experintial

5. sine and cosine.

SOFTWARE REQUIRED:

MATLAB version 7.2

THEORY:

A Discrete time signal is discrete in time and continuous in amplitude.

Unit Step u(n)

The amplitude of the signal is one for

0 ≥ n

and zero for

0 ≤ n

¹

'

¹

≤

≥

·

0 , 0

0 , 1

) (

n for

n for

n u

Unit Ramp r(n)

This is the signal whose amplitude increases linearly with time

¹

'

¹

≤

≥

·

0 , 0

0 ,

) (

n for

n for n

n r

Exponential e(n)

It varies exponentially with time

¹

'

¹

≤

≥

·

0 , 0

0 , ) exp(

) (

n for

n for n

n e

ALGORITHM:

Step 1: Start the program

Step 2: Define the amplitude sequence

Step 3: Give the necessary label

Step 4: Draw the amplitude versus time period graph

Step 5: Stop the process

The above steps are repeated for the generation of all the above

mentioned signals by altering the time instant and the amplitude values.

Program:

%UNIT IMPULSE

s=1,d=0;

subplot(2,2,1);

stem(d,s);

grid on;

xlabel('n---->');

ylabel('Amp---->');

title('UNIT IMPULSE');

%UNIT IMPULSE

s=[zeros(1,10) 1 zeros(1,10)];

subplot(2,2,2);

plot(s);

grid on;

xlabel('n---->');

ylabel('Amp---->');

title('UNIT IMPULSE');

%UNIT IMPULSE

s=[zeros(1,10) 1 zeros(1,10)];

d=-10:1:10;

subplot(2,2,3);

stem(d,s);

grid on;

xlabel('n---->');

ylabel('Amp---->');

title('UNIT IMPULSE');

%UNIT IMPULSE

s=[zeros(1,1000) 1 zeros(1,1000)];

d=-1000:1:1000;

subplot(2,2,4);

plot(d,s);

grid on;

xlabel('n---->');

ylabel('Amp---->');

title('UNIT IMPULSE');

%UNIT STEP SEQUENCE

clear all;

N=5;

X=ones(1,N);

n=0:1:N-1;

figure,subplot(2,2,1);

plot(n,X);

xlabel('n---->'),ylabel('X(n)---->');

title('UNIT STEP SEQUENCE');

%UNIT STEP SEQUENCE

x=-50:50;

y=[zeros(1,50) ones(1,51)];

subplot(2,2,2);stem(x,y);

xlabel('n---->'),ylabel('X(n)---->');

title('UNIT STEP SEQUENCE');

%UNIT RAMP

n=1:1:20;

subplot(2,2,3);

plot(n,n);

grid on;

xlabel('n---->');

ylabel('Amp---->');

title('UNIT RAMP');

%GROWING EXPONENTIAL SEQUENCE 1

n=0:1:10;

x1=exp(n);

subplot(2,2,4);

plot(n,x1);

xlabel('n---->');

ylabel('x1(n)---->');

title('GROWING EXPONENTIAL 1');

%GROWING EXPONENTIAL SEQUENCE 2

x2=-50:50;

y=[zeros(1,50) exp([0:0.1:5])];

figure

subplot(2,2,1);

stem(x2,y);

xlabel('n---->');

ylabel('x2(n)---->');

title('GROWING EXPONENTIAL 2');

%SINUSOIDAL SIGNAL

n=0:.5:(5*pi);

x3=sin(n);

subplot(2,2,3);

plot(n,x3);

xlabel('n---->');

ylabel('x3(n)---->');

title('SINE WAVE');

RESULT:

Thus a MATLAB program is written for generating of signals and

output is obtained.

Exp.No.2

Date:

LINEAR AND CIRCULAR CONVOLUTION

AIM:

To do linear and circular convolution of the discrete time sequence

and plot the sequences.

SOFTWARE REQUIRED:

MATLAB version 7.2

THEORY:

LINEAR CONVOLUTION

It is a generation used to find output and LDI / DT system in

time domain.

Let x(n) be the input to the LTI system and H(n) is the impulse

response of the LTI system then the output y(n) of the system is given

by

∑

·

·

− ⋅ ·

∗ ·

1

0

) ( ) ( ) (

) ( ) ( ) (

µ

k

k n x k h n y

n h n x n y

The above equation is called linear convolution equation. This

equation is involved using convolution.

Let n

1

be the sequence of input

n

2

be the sequence of impulse response

The length of the output sequence

1

2 1 3

− + · n n n

CIRCULAR CONVOLUTION:

In circular convolution it is necessary the sequence must be same. It

is similar to linear convolution except the shifting is performed in circular

convolution.

∑

·

·

− ⋅ ·

∗ ·

1

0

2 1

) ( ) ( ) (

) ( ) ( ) (

µ

k

k n x k x n y

n h n x n y

ALGORITHM:

Step 1: Start the program

Step 2: Get the first sequence

Step 3: Get the second sequence

Step 4: Convolution of both the sequence

Step 5: Plot the sequence

Step 6: Stop the process

LINEAR CONVOLUTION

clc;

clear all;

close all;

x=input('enter the x sequence');

n1=length(x);

o1=input('enter the origin of x');

h=input('enter the h sequence' );

n2=length(h);

o2=input('enter the origin of h');

o3=o1+o2;

yt=o3+n1+n2-2;

y=conv(x,h);

t=o3:1:yt;

figure ,stem(t,y);

tx=o1:1:n1+o1-1;

ty=o2:1:n2+o2-1;

figure , subplot(2,1,1),stem(tx,x);

subplot(2,1,2),stem(ty,h);

INPUT COMMAND :

enter the x sequence[ ]

enter the origin of x0

enter the h sequence[ ]

enter the origin of h-1

CIRCULAR CONVOLUTION

clc;

clear all;

close all;

x1=input('enter the x1 sequence');

n1=length(x1);

o1=input('enter the origin of x1');

x2=input('enter the x2 sequence' );

n2=length(x2);

o2=input('enter the origin of x2');

if (n1>n2)

x2=[x2 zeros(1,n1-n2)];

N=n1;

elseif (n1<n2)

x1=[x1 zeros(1,n2-n1)];

N=n2;

end

N=max(n1,n2);

y=cconv(x1,x2,N);

yt=0:1:N-1;

tx1=o1:1:n1-1;

tx2=o2:1:n2-1;

figure,stem(tx1,x1);

figure,stem(tx2,x2); HC

figure,stem(yt,y);

INPUT COMMAND :

enter the x1 sequence[ ]

enter the origin of x10

enter the x2 sequence[ ]

enter the origin of x20

RESULT:

Thus a MATLAB program for Linear and Circular Convolution has

been written and output is verified.

Exp.No.4

Date:

SPECTRUM ANALYSIS USING FFT

AIM:

To write a Matlab program to find spectrum analysis of discrete and

continuous time FFT

SOFTWARE REQUIRED:

MATLAB version 7.2

THEORY:

Fourier transform used for frequency analysis of the signal. It is given

as

∑

∞

−∞ ·

−

∫

⋅ ·

n

n

e n x n x DFT

π

) ( ) ( ,

Here r is the frequency and has image of 0 to 27. These are several

methods to find DFT and IDFT. FFT is fast and efficient method. It is a

finite duration sequence and is obtained by sampling transfer function

) (

3ϖ

e x

at N equally spaced points over an interval ‘ω’.

π

π

ω

ω

2 0 ,

2

) ( ) (

3

≤ ≤ · · k

N

k

e x k x

IDFT, ∑

−

·

− ≤ ≤

∫

⋅ ·

1

0

2

1 0 , ) (

1

) (

N

k

N Kn

N n e K X

N

n X

π

ALGORITHM:

Step 1: Start the program

Step 2: Initialize the give sequence

Step 3: Assign the length of the sequence

Step 4: Plot the sequence of magnitude and phase.

Step 5: Stop the process

FFT (DISCRETE)

clear all

x=input('enter the sequence');

N=length(x);

y=fft(x,N);

k=0:1:N-1;

Magy=abs(y);

Angy=angle(y);

Subplot(2,1,1),stem(k,Magy);

Xlabel(‘k’),ylabel(‘Magnitude of y’);

Subplot(2,1,2), stem(k,Angy);

Xlabel(‘k’),ylabel(‘Angle of y’);

INPUT:

Enter the sequence[ ]

FFT PSD (DISCRETE)

clear all

x=input('enter the sequence');

N=length(x);

y=fft(x,N)

k=0:1:N-1;

Magy=abs(y)

Angy=angle(y)

p=y.*conj(y)/N

Subplot(2,1,1),stem(k,Magy);

xlabel('k'),ylabel('Magnitude of y');

Subplot(2,1,2), stem(k,Angy);

xlabel('k'),ylabel('Angle of y');

figure,

stem(k,p);

INPUT:

Enter the sequence[ ]

FFT PSD(CONTINOUS)

clear all

fs=input('Enter the Sampling Frequency');

N=input('Enter the length of DFT');

f=input('Enter the frequency of the input signal');

k=0:1:N-1;

x=input('Enter the input signal');

%x=sin(2*pi*f*k*(1/fs));

y=fft(x,N)

Magy=abs(y)

Angy=angle(y)

p=y.*conj(y)/N

Subplot(2,1,1),stem(k,Magy);

xlabel('k'),ylabel('Magnitude of y');

Subplot(2,1,2), stem(k,Angy);

xlabel('k'),ylabel('Angle of y');figure,

stem(k,p);

INPUT:

Enter the Sampling Frequency

Enter the length of DFT

Enter the frequency of the input signal

Enter the input signal

FFT PSD (CONTINOUS)—VERIFICATION USING

AUTOCORRELATION

clear all

fs=input('Enter the Sampling Frequency');

N=input('Enter the length of DFT');

f=input('Enter the frequency of the input signal');

k=0:1:N-1;

x=input('Enter the input signal');

%x=sin(2*pi*f*k*(1/fs));

y=fft(x,N)

p=xcorr(x,x)

y1=fft(p,N)

Magy=abs(y)

Angy=angle(y)

p=y.*conj(y)/N

Subplot(2,1,1),stem(k,Magy);

xlabel('k'),ylabel('Magnitude of y');

Subplot(2,1,2), stem(k,Angy);

xlabel('k'),ylabel('Angle of y');

figure,

stem(k,y1);

RESULT

Thus a MATLAB program for Spectrum analysis using FFT has been

written and output has been verified.

Exp.No.3

Date:

AUTOCORRELATION AND CROSS CORRELATION

AIM:

To find the autocorrelation of given signal and cross correlation of the

same signal.

SOFTWARE REQUIRED:

MATLAB version 7.2

THEORY:

Autocorrelation of the given functions is calculated using the formula,

1 1

) 1 ( ) 1 ( ) ( ) (

≤ ≤ −

− ≤ ≤ − − − ⋅ ·

∑

∞

−∞ ·

n

N n N where n k x k x R

k

xx

Cross correlation of the given function is calculated using the formula,

1 1

) 1 ( ) 1 ( ) ( ) ( ) (

≤ ≤ −

− ≤ ≤ − − − ⋅ ·

∑

∞

−∞ ·

n

N n N where n k y k x n R

k

xy

ALGORITHM:

Step 1: Start the program

Step 2: Enter the program

Step 3: Run the program

Step 4: Calculate the cross correlation of sequence

Step 5: Calculate the autocorrelation of sequence

Step 6: Plot both the sequence

Step 7: Stop the process

Program:

AUTO CORRELATION

clc;

clear all;

close all;

x=input('Enter the input sequence');

y=xcorr(x)

xl=length(x);

xt=0:1:xl-1;

stem(xt,x);

xlabel('n---->');

ylabel('Amplitude');

title('Input sequence');

yt=-(xl-1):1:(xl-1);

figure,

stem(yt,y);

xlabel('n---->');

ylabel('Amplitude');

title ('Output sequence');

INPUT :

Enter the input sequence[ ]

CROSS CORRELATION

clc;

clear all;

close all;

x=input('Enter the first input sequence');

y=input('Enter the second input sequence');

z=xcorr(x,y)

x1=length(x);

xt=0:1:x1-1;

subplot(2,1,1),stem(xt,x);

xlabel('n---->');

ylabel('Amplitude');

title('first Input sequence');

subplot(2,1,2),stem(xt,y);

xlabel('n---->');

ylabel('Amplitude');

title('second Input sequence');

yt=-(x1-1):1:(x1-1);

figure,

stem(yt,z);

xlabel('n---->');

ylabel('Amplitude');

title('Output sequence');

INPUT:

Enter the first input sequence[ ]

Enter the second input sequence[ ]

RESULT

Thus a MATLAB program for autocorrelation and cross correlation

has been written and output has been verified.

Exp.No.6a FILTER DESIGN ANALYSIS –IIR FILTER

Date:

DESIGN OF BUTTERWORTH IIR FILTER

AIM:

To design the IIR filter and plot the frequency response.

SOFTWARE REQUIRED:

MATLAB version 7.2

THEORY:

Digital filters are used for two digital purposes

(i) Separating a signal that has been combined.

(ii) Distortion of signal that has been distorted in same way.

IIR filters are an efficient way of achieving along impulse response

without having to perform a long convolution. They execute very rapidly

but have less performance and flexibility than other digital filter.

Since the impulse response is composed of decaying exponential

signal, these signal filters are called as IIR filters. They are called as receiver

filter because digital filter are made up of recursion. Recursion filters are

previously calculated values from the output besides part from the output.

These filters are defined as with correspondence with analog filter between

butterworth and chebyshev filter.

The impulse response of these filter are composed of sinusoidal that

exponentially decay in amplitude of the input is a simple impulse. In

principle, this mares the impulse response infinitely long. However, the

amplitude eventually drop below the round of noise of the system. The

remaining samples are ignored because of the characterization of filter are

called IIR filter.

ALGORITHM:

Step 1: Start the program

Step 2: Assign the given specification to variables

Step 3: Compute the order of the filter using in-built

function

Step 4: Computer the function of co-efficient using

appropriate function

Step 5: Plot the frequency response of IIR filter

Step 6: Stop the process

IIR LOW PASS FILTER WITH BUTTERWORTH

CHARACTERISTICS (using Impulse Invariant

method)

Design an IIR low pass filter using Impulse invariant method and

MATLAB. The low pass filter with Butterworth characteristic is

required to meet the following specifications :

Cutoff frequency = 150Hz

Sampling frequency = 1.28KHz

Filter order = 2

a) Determine, using the impulse invariant method and

MATLAB,

i) The coefficients, poles and zeros of the

frequency-scaled analog filter.

ii)The coefficients, poles and zeros of the IIR

discrete filter. Write down its transfer function.

b) Plot the magnitude-frequency response and the pole-

zero diagram of the discrete filter.

---------------------------------------------------------

%BUTTERWORTH LPF USING IMPULSE INVARIANT METHOD

clc;

Fs=1280; %sampling freq

fc=150; %cutoff freq

WC=2*pi*fc; %cutoff freq in radian

N=2;

[b,a]=butter(N,WC,'s')%create an analog filter

%[b,a] = butter(n,Wn,'s')designs an order n lowpass analog Butterworth

filter with angular cutoff frequency Wn rad/s. It returns the filter coefficients

in the length n+1 row vectors b and a,in descending powers of s, derived

from this transfer function:

H(s)=[b(1)s^n+b(2)s^n-1+....+b(n+1)]/

[s^n+a(2)s^n-1+....+a(n+1)]

%[b,a] = butter(n,Wn) designs an order n lowpass digital Butterworth filter

with normalized cutoff frequency Wn. It returns the filter coefficients in

length n+1 row vectors b and a, with coefficients in descending powers of z.

H(z)=[b(1)+b(2)z^-1+....+b(n+1)z^-n]/

[1+a(2)z^-1+....+a(n+1)z^-n]

[z,p,k]=butter(N,WC,'s')%returns the zeros and poles in length n column

vectors z(zeros) and p(poles), and the gain in the scalar k.

[bz,az]=impinvar(b,a,Fs)%determine the coeff of IIR filter

%[bz,az] = impinvar(b,a,fs) creates a digital filter with numerator and

denominator coefficients bz and az, respectively, whose impulse response is

equal to the impulse response of the analog filter with coefficients b and

a,scaled by 1/fs. If you leave out the argument fs,or specify fs as the empty

vector [],it takes the default value of 1 Hz.

subplot(2,1,1)

[H,f]=freqz(bz,az,512,Fs);%[h,f] = freqz(b,a,f,fs) returns the frequency

response vector h and the corresponding frequency vector f for the digital

filter whose transfer function represented in the vectors b and a, respectively.

The frequency response vector h is calculated at the frequencies(in Hz)

supplied in the vector f. The vector f can be any length. For this syntax, the

frequency response is calculated using the sampling frequency specified by

the scalar fs (in hertz). The frequency vector f has values ranging from 0 to

fs/2Hz.

plot(f,20*log10(abs(H))),grid

xlabel('Frequency(Hz)')

ylabel('Magnitude Response(dB)')

subplot(2,1,2)%plot ploe-zero diagram

zplane(bz,az)

zz=roots(bz) %Determine poles and zeros

pz=roots(az)

output : BUTTERWORTH LPF USING IMPULSE INVARIANT

METHOD

b =

1.0e+005 *

0 0 8.8826

a =

1.0e+005 *

0.0000 0.0133 8.8826

z =

Empty matrix: 0-by-1

p =

1.0e+002 *

-6.6643 + 6.6643i

-6.6643 - 6.6643i

k =

8.8826e+005

bz =

0 0.3078 0

az =

1.0000 -1.0308 0.3530

zz =

0

pz =

0.5154 + 0.2955i

0.5154 - 0.2955i

IIR LOW PASS FILTER WITH BUTTERWORTH

CHARACTERISTICS (using Bilinear Z-Transform method)

Design an IIR low pass filter using BiLinear Z-Transform method and

MATLAB. The low pass filter with Butterworth characteristic is

required to meet the following specifications :

Cutoff frequency = 150Hz

Sampling frequency = 1.28KHz

Filter order = 2

a) Determine, using the BiLinear Z-Transform method

and MATLAB,

i) The coefficients, poles and zeros of the

discrete filter. Write down its transfer function.

b) Plot the magnitude-frequency response and the pole-

zero diagram of the discrete filter.

---------------------------------------------------------

%BUTTERWORTH LPF USING BLT METHOD

clc;

Fs=1280;%sampling freq

fc=150;%cutoff freq

N=2;

FN=Fs/2;

Fc=fc/FN;%normalized cutoff frequency

[bz,az]=butter(N,Fc)%create an analog filter %[b,a] = butter(n,Wn) designs

an order n lowpass digital Butterworth filter with normalized cutoff

frequency Wn. It returns the filter coefficients in length n+1 row vectors b

and a, with coefficients in descending powers of z.

H(z)=[b(1)+b(2)z^-1+....+b(n+1)z^-n]/

[1+a(2)z^-1+....+a(n+1)z^-n]

[z,p,k]=butter(N,Fc)%returns the zeros and poles in length n column vectors

z(zeros) and p(poles), and the gain in the scalar k.

subplot(2,1,1)

[H,f]=freqz(bz,az,512,Fs);%[h,f] = freqz(b,a,f,fs) returns

the frequency response vector h and the corresponding frequency vector f for

the digital filter whose transfer function represented in the vectors b and a,

respectively. The frequency response vector h is calculated at the

frequencies(in Hz) supplied in the vector f. The vector f can be any length.

For this syntax, the frequency response is calculated using the sampling

frequency specified by the scalar fs (in hertz). The frequency vector f has

values ranging from 0 to fs/2Hz.

plot(f,abs(H)),grid

xlabel('Frequency(Hz)')

ylabel('Magnitude Response(dB)')

subplot(2,1,2)%plot ploe-zero diagram

zplane(bz,az)

zz=roots(bz); %Determine poles and zeros

pz=roots(az);

Output: BUTTERWORTH LPF USING BLT METHOD

bz =

0.0878 0.1756 0.0878

az =

1.0000 -1.0048 0.3561

z =

-1

-1

p =

0.5024 + 0.3220i

0.5024 - 0.3220i

k =

0.0878

IIR BAND PASS FILTER WITH BUTTERWORTH

CHARACTERISTICS (using Bilinear Z-Transform method)

Design an IIR Band pass filter using Bilinear Z-Transform method and

MATLAB. The Band pass filter with Butterworth characteristic is

required to meet the following specifications :

Pass band = 200–300Hz

Sampling frequency = 2KHz

Filter order = 8

a) Determine, using the BiLinear Z-Transform method

and MATLAB,

i) The coefficients, poles and zeros of the

Discrete filter. Write down its transfer function.

b) Plot the magnitude-frequency response and the pole-

zero diagram of the discrete filter.

---------------------------------------------------------

%BUTTERWORTH BPF USING BLT METHOD

Fs=2000;

FN=Fs/2;%Sampling freq

fc1=200/FN;

fc2=300/FN;

[b,a]=butter(4,[fc1,fc2]) %create/digitize analog filter %Filter order used in

the m-file is half that specified in the design problem : for BPF and BSF, the

order is 2N.

[z,p,k]=butter(4,[fc1,fc2])

subplot(2,1,1) %plot magnitude-frequency response

[H,f]=freqz(b,a,512,Fs);

plot(f,abs(H))

xlabel('Frequency (Hz)')

ylabel('Magnitude Response')

subplot(2,1,2) %plot pole-zero diagram

zplane(b,a)

Output: BUTTERWORTH BPF USING BLT METHOD

b =

Columns 1 through 7

0.0004 0 -0.0017 0 0.0025 0 -0.0017

Columns 8 through 9

0 0.0004

a =

Columns 1 through 7

1.0000 -5.1408 13.1256 -20.9376 22.6982 -17.0342 8.6867

Columns 8 through 9

-2.7672 0.4383

z =

1

1

1

1

-1

-1

-1

-1

p =

0.5601 + 0.7475i

0.5601 - 0.7475i

0.5800 + 0.6286i

0.5800 - 0.6286i

0.6656 + 0.5628i

0.6656 - 0.5628i

0.7647 + 0.5648i

0.7647 - 0.5648i

k =

4.1660e-004

IIR HIGH PASS FILTER WITH BUTTERWORTH

CHARACTERISTICS (using Bilinear Z-Transform method)

Design an IIR high pass Butterworth filter with the following

specifications using BiLinear Z-Transform method and MATLAB.

Passband = 2-4KHz

Stopband = 0-500Hz

Passband ripple = 3dB

Stopband attenuation = 20dB

Sampling frequency = 8KHz

a) Pass and stop band edge frequencies

a) Determine, using the BiLinear Z-Transform method

and MATLAB,

i) The order,coefficients, poles and zeros of the

discrete filter. Write down its transfer function.

b) Plot the magnitude-frequency response and the pole-

zero diagram of the discrete filter.

--------------------------------------------------------------------------------

%BUTTERWORTH HPF USING BLT METHOD

Fs=8000;%Sampling frequency

Ap=3;%Attenuation in passband

As=20;%Attenuation in stopband

Wp=2000/4000

Ws=500/4000

[N,wc]=buttord(Wp,Ws,Ap,As) %Determine filter order

[zz,pz,kz]=butter(N,2000/4000,'high') %Digitize filter

[b,a]=butter(N,2000/4000,'high')

subplot(2,1,1) %plot magnitude-frequency response

[H,f]=freqz(b,a,512,Fs);

plot(f,abs(H));

xlabel('Frequency (Hz)')

ylabel('Magnitude Response')

subplot(2,1,2) %plot pole-zero diagram

zplane(b,a)

Output : BUTTERWORTH HPF USING BLT METHOD

Wp =

0.5000

Ws =

0.1250

N =

2

wc =

0.3567

zz =

1

1

pz =

0.0000 + 0.4142i

0.0000 - 0.4142i

kz =

0.2929

b =

0.2929 -0.5858 0.2929

a =

1.0000 -0.0000 0.1716

IIR BAND STOP FILTER WITH BUTTERWORTH

CHARACTERISTICS (using Bilinear Z-Transform method)

Design an IIR Band stop Butterworth filter with the following

specifications using BiLinear Z-Transform method and MATLAB.

Lower Passband = 0-50Hz

Upper Passband = 450-500Hz

Stopband = 200-300Hz

Passband ripple = 3dB

Stopband attenuation = 20dB

Sampling frequency = 1KHz

a) Pass and stop band edge frequencies

a) Determine, using the BiLinear Z-Transform method

and MATLAB,

i) The order,coefficients, poles and zeros of the

discrete filter. Write down its transfer function.

b) Plot the magnitude-frequency response and the pole-

zero diagram of the discrete filter.

--------------------------------------------------------------------------------

%BUTTERWORTH BSF USING BLT METHOD

Fs=1000;%Sampling frequency

Ap=3;%Attenuation in passband

As=20;%Attenuation in stopband

Wp=[50/500, 450/500]%Bandedge frequencies

Ws=[200/500, 300/500]

[N,wc]=buttord(Wp,Ws,Ap,As) %Determine filter order

[zz,pz,kz]=butter(N,Ws,'stop') %Digitize filter

[b,a]=butter(N,Ws,'stop')

subplot(2,1,1) %plot magnitude-frequency response

[H,f]=freqz(b,a,512,Fs);

plot(f,abs(H));

xlabel('Frequency (Hz)')

ylabel('Magnitude Response')

subplot(2,1,2) %plot pole-zero diagram

zplane(b,a)

Output : BUTTERWORTH BSF USING BLT METHOD

Wp =

0.1000 0.9000

Ws =

0.4000 0.6000

N =

2

wc =

0.2461 0.7539

zz =

0.0000 + 1.0000i

0.0000 - 1.0000i

0.0000 + 1.0000i

0.0000 - 1.0000i

pz =

-0.1884 + 0.7791i

-0.1884 - 0.7791i

0.1884 + 0.7791i

0.1884 - 0.7791i

kz =

0.6389

b =

0.6389 -0.0000 1.2779 -0.0000 0.6389

a =

1.0000 -0.0000 1.1430 -0.0000

RESULT

Thus, the Butterworth Low pass and high pass IIR filter was designed

and frequency response was plotted using MATLAB.

Exp.No.6b

Date:

DESIGN OF CHEBYSHEV TYPE I FILTER

AIM:

To design Chebyshev type I IIR filter and plot the frequency response.

SOFTWARE REQUIRED:

MATLAB version 7.2

THEORY:

These are two types of Chebyshev filters. Type I Chebyshev filters are

all pole filters that exhibit eqrilripple behavior is pass band and a monolonic

characteristics in stop band. The magnitude sequence of N

th

order is

expressed as,

( ) .. ,......... 2 , 1

1

2 2

2

·

,

_

¸

¸

Σ

·

∫

N

rp

r

C H

r H

N

Pass band filter allows only a band of frequencies r

1

to r

2

to pass and

stops all other frequencies. Band reject filter rejects all the frequencies

between r

1

to r

2

and allows other frequencies.

ALGORITHM:

Step 1: Start the program

Step 2: Compute the stop-band and pass-band attenuation

Step 3: Computer the order

Step 4: Find the transfer function co-efficient

Step 5: Plot the magnitude response of respective filter

RESULT

Thus, the ideal characteristics of Chebyshev type I filter was designed

and frequency was plotted.

Exp.No.5 FILTER DESIGN ANALYSIS –FIR FILTER

Date:

DESIGN OF FIR FILTERS USING WINDOW TECHNIQUES

AIM:

To design FIR filter using various windows techniques and plot the

frequency response.

SOFTWARE REQUIRED:

MATLAB version 7.2

THEORY:

HAMMING WINDOW:

Hamming window is most commonly used window in speech

processing. This window also has bell like shape. Its first and last samples

are not zero. Its show that the sketch and magnitude response of this

window. It has reduced side lobes but slightly increase main lobe. The side

lobes are higher than the Blackmann window.

KAISER WINDOW:

Kaiser window allow separate control of width of the main lobe

and attenuation of side lobe. If wk(n) has two parameter the length (mt) and

shape B. It can be selected independently in Kaiser Window. Its first and

last samples are not zero. The shape of the window depends upon values of

M and β. It shows the magnitude response of Kasier Window. The shape of

main lobe and side lobe can be adjusted by selection of ‘M’ and ‘β’. It is

most commonly used in digital filter.

HANNING WINDOW:

Hanning Window has shape simplar to those of Blackmann and

Hamming. Its first and last samples are zero. It is given as,

¹

¹

¹

'

¹

− ·

,

_

¸

¸

−

−

·

otherwise

M n

M

n

n w

HN

, 0

1 ....... .......... , 1 , 0 ,

1

2

cos 1

2

1

) (

π

This window is commonly used for spectrum analysis, speech and

music processing. In the magnitude response of Hanning window, we

observe that is has narrow main, but few side lobes are significant. Then

side lobes are reduced rapidly

ALGORITHM:

Step 1: Get the pass band and stop band ripples

Step 2: Get the pass band and stop band edge frequencies

Step 3: Get the sampling frequency.

Step 4: Calculated the order of filter

Step 5: Find the Window co-efficient

Step 6: Draw the magnitude and phase response

.

FIR BAND PASS FILTER USING WINDOW

Determine the coefficients and plot the magnitude-frequency response

of a bandpass FIR filter, using an appropriate window that meets the

following specifications : passband = 150-250Hz,transition width =

50Hz,passband ripple = 0.1dB,stopband

Attenuation = 60dB,sampling frequency = 1kHz.

FS=1000; % Sampling frequency

FN=FS/2;%Nyqiust frequency

N=73;%Filter length

beta=5.65;%Kaiser window ripple parameter

fc1=125/FN;

fc2=275/FN;%Normalised cutoff frequencies

FC=[fc1 fc2];%Band edge frequency vector

k_window=kaiser(N,beta)

stem(k_window);grid on

xlabel('Sample number n')

ylabel('Amplitude (dB)')

figure,

hn=fir1(N-1,FC,kaiser(N,beta))%Obtain windowed filter coefficients

stem(hn);grid on

xlabel('Sample number n')

ylabel('Impulse response of designed filter(dB)')

figure,

[H,f]=freqz(hn,1,512,FS);%Compute frequency response

mag=20*log10(abs(H));

plot(f,mag),grid on

xlabel('Frequency (Hz)')

ylabel('Magnitude response, Gain (dB)')

FIR LOWPASS FILTER USING WINDOW

Obtain the coefficients of an FIR lowpass filter to meet the specifications

given using the window method: passband edge frequency

=1.5kHz,transition width = 0.5kHz,stopband attenuation <

50dB,sampling frequency = 5kHz.

clc;

FS=input('enter the sampling freq'); % Sampling frequency

delF=input('enter the transition width');

N=round((3.1*FS)/delF)%Filter length

FC=input('enter the cutoff freq');

FC1=FC/FS;

stem(hanning(N)),grid on

xlabel('Sample number n')

ylabel('Amplitude (dB)')

figure,

hn=fir1(N-1,FC1,hanning(N))%Obtain windowed filter coefficients

stem(hn),grid on

xlabel('Sample number n')

ylabel('Impulse response of designed filter(dB)')

figure,

[H,f]=freqz(hn,1,512,FS)%Compute frequency response

mag=20*log10(abs(H));

plot(f,mag),grid on

xlabel('Frequency (Hz)')

ylabel('Magnitude response (dB)')

Input :

enter the sampling freq5000

enter the transition width500

enter the cutoff freq1500

FIR HIGH PASS FILTER USING WINDOW

Obtain the coefficients of an FIR highpass filter to meet the

specifications given using the window method: passband edge frequency

= 1.2kHz, transition width = 0.5kHz,stopband attenuation >

50dB,sampling frequency = 8kHz.

clc;

FS=input('enter the sampling freq');% Sampling frequency

N=input('enter the length of the filter');

delF=round((3.3*FS)/N)%transition width

FC=input('enter the cutoff freq');

FC1=FC/FS;

stem(hamming(N)),grid on

xlabel('Sample number n')

ylabel('Amplitude (dB)')

figure,

hn=fir1(N-1,FC1,'high',hamming(N))%Obtain windowed filter coefficients

stem(hn),grid on

xlabel('Sample number n')

ylabel('Impulse response of designed filter(dB)')

figure,

[H,f]=freqz(hn,1,512,FS)%Compute frequency response

mag=20*log10(abs(H));

plot(f,mag),grid on

xlabel('Frequency (Hz)')

ylabel('Magnitude response (dB)')

Input :

enter the sampling freq8000

enter the transition width500

enter the cutoff freq1200

FIR BAND STOPFILTER USING WINDOW

Determine the coefficients and plot the magnitude-frequency response

of a bandstop FIR filter, using an appropriate window that meets the

following specifications : passband = 150-250Hz,filter length =

27,passband ripple = 0.1dB,stopband

Attenuation = 20dB,sampling frequency = 1kHz.

FS=1000; % Sampling frequency

FN=FS/2;%Nyqiust frequency

N=27;%Filter length

fc1=125/FN;

fc2=275/FN;%Normalised cutoff frequencies

FC=[fc1 fc2];%Band edge frequency vector

r_window=boxcar(N)

stem(r_window);grid on

xlabel('Sample number n')

ylabel('Amplitude (dB)')

figure,

hn=fir1(N-1,FC,'stop',boxcar(N))%Obtain windowed filter coefficients

stem(hn);grid on

xlabel('Sample number n')

ylabel('Impulse response of designed filter(dB)')

figure,

[H,f]=freqz(hn,1,512,FS);%Compute frequency response

mag=20*log10(abs(H));

plot(f,mag),grid on

xlabel('Frequency (Hz)')

ylabel('Magnitude response, Gain (dB)')

HAMMING WINDOW

clc:

Clear all;

Close all;

fs=input (‘stop band frequency of , fs=’) ;

fp=input (‘pass band frequency of, fp=’) ;

f=input (‘sampling frequency, f=’) ;

dels=input(‘stop band error tolerance, dels=’) ;

delp=input (‘pass band error tolerance, delp=’) ;

wp=(2*fp) /f ;

ws=(2*fs) / f ;

rp=-20*log10 (1-delp) ;

rs=-20*log10 (dels)

num=-20log(sqrt(delp*dels))-13 ;

dem=14.6*(fs-fp) / f ;

n=cell (num / dem) ;

n1=n+1 ;

if (rem (n,2)=0)

n1=n ;

n=n-1 ;

end

y=hamming (n1) ;

% low pass filter

b=firl (n, wp, y) ;

[h,w]=freqz (b,1,512) ;

m=20*log(abs (h) ;

subplot (2,2,1);

plot(1/pi,m) ;

grid ;

ylabel (‘Gain in dB’) ;

xlabel (‘Normalised Freq’) ;

title (‘Response of LPF’);

%High pass filter

b=firl (n, wp, ‘high’ , y) ;

[h, w]=freqz (b,1,512) ;

m=20*log(abs(h)) ;

subplot(2,2,2) ;

plot(w/pi,m) ;

grid ;

ylabel (‘Gain in dB’) ;

xlabel (‘Normalised Freq’) ;

title (‘Response of HPF’) ;

%Band pass filter

wn=[wp ws ] ;

b=firl (n,wn, ‘bandpass’, y) ;

[h,w]=freqz (b,1,512) ;

m=20*log(abs(h));

subplot (2,2,3)

plot(w/pi,m) ;

grid ;

ylabel (‘Gain in dB’) ;

xlabel (‘Normalised Freq’) ;

title (‘Response of HPF’) ;

%Band pass filter

wn=[wp ws ] ;

b=firl (n,wn, ‘stop’, y) ;

[h,w]=freqz (b,1,512) ;

m=20*log(abs(h));

subplot (2,2,4)

plot(w/pi,m) ;

grid ;

ylabel (‘Gain in dB’) ;

xlabel (‘Normalised Freq’) ;

title (‘Response of HPF’) ;

gtext (‘Frequency response Hamming window’) ;

KAISER WINDOW

clc:

Clear all;

Close all;

fs=input (‘stop band frequency of , fs=’) ;

fp=input (‘pass band frequency of, fp=’) ;

f=input (‘sampling frequency, f=’) ;

ds=input(‘stop band error tolerance, dels=’) ;

dp=input (‘pass band error tolerance, delp=’) ;

wp=(2*fp) /f ;

ws=(2*fs) / f ;

rp=-20*log10 (1-dp) ;

rs=-20*log10 (ds)

num=-20log(sqrt(dp*ds))-13 ;

dem=14.6*(fs-fp) / f ;

n=cell (num / dem) ;

n1=n+1 ;

if (rem (n,2)=0)

n1=n ;

n=n-1 ;

end

y=kaiser (n, 0.75) ;

% low pass filter

b=firl (n, wp, ‘low’ y) ;

[h,w]=freqz (b,1,512) ;

m=20*log(abs (h) ;

subplot (2,2,1);

plot(w/pi,m) ;

grid ;

ylabel (‘Gain in dB’) ;

xlabel (‘Normalised Freq’ (hz)*) ;

title (‘Frequency Response of LPF using Kaiser window’);

%High pass filter

b=firl (n, wp, ‘high’ , y) ;

[h, w]=freqz (b,1,512) ;

m=20*log(abs(h)) ;

subplot(2,2,2) ;

plot(w/pi,m) ;

grid ;

ylabel (‘Gain in dB’) ;

xlabel (‘Normalised Freq’) ;

title (‘Response of HPF using Kaiser window’) ;

%Band pass filter

wn=[wp ws ] ;

b=firl (n,wp, ‘bandpass’, y) ;

[h,w]=freqz (b,1,512) ;

m=20*log(abs(h));

subplot (2,2,3)

plot(w/pi,m) ;

grid ;

ylabel (‘Gain in dB’) ;

xlabel (‘Normalised Freq’) ;

title (‘Response of BPF using Kaiser window’) ;

%Band pass filter

wn=[wp ws ] ;

b=firl (n,wn, ‘stop’, y) ;

[h,w]=freqz (b,1,512) ;

m=20*log(abs(h));

subplot (2,2,4)

plot(w/pi,m) ;

grid ;

ylabel (‘Gain in dB’) ;

xlabel (‘Normalised Freq’) ;

title (‘Response of BSF using Kaiser window’) ;

gtext (‘Frequency response Hamming window’) ;

HANNING WINDOW

clc:

Clear all;

Close all;

fs=input (‘stop band frequency of , fs=’) ;

fp=input (‘pass band frequency of, fp=’) ;

f=input (‘sampling frequency, f=’) ;

ds=input(‘stop band error tolerance, dels=’) ;

dp=input (‘pass band error tolerance, delp=’) ;

wp=(2*fp) /f ;

ws=(2*fs) / f ;

rp=-20*log10 (1-delp) ;

rs=-20*log10 (dels)

num=-20log(sqrt(delp*dels))-13 ;

dem=14.6*(fs-fp) / f ;

n=cell (num / dem) ;

n1=n+1 ;

if (rem (n,2)~=0)

n1=n ;

n=n-1 ;

end

y=hanning (n1) ;

% low pass filter

b=firl (n, wp, y) ;

[h,w]=freqz (b,1,512) ;

m=20*log(abs (h) ;

subplot (2,2,1);

plot(w/pi,m) ;

grid ;

ylabel (‘Gain in dB’) ;

xlabel (‘Normalised Freq’) ;

title (‘Response of LPF using Hanning window’);

%High pass filter

b=firl (n, wp, ‘high’ , y) ;

[h, w]=freqz (b,1,512) ;

m=20*log(abs(h)) ;

subplot(2,2,2) ;

plot(w/pi,m) ;

grid ;

ylabel (‘Gain in dB’) ;

xlabel (‘Normalised Freq’) ;

title (‘Response of HPF using Hanning window’) ;

%Band pass filter

wn=[wp ws ] ;

b=firl (n,wn, ‘bandpass’, y) ;

[h,w]=freqz (b,1,512) ;

m=20*log(abs(h));

subplot (2,2,3)

plot(w/pi,m) ;

grid ;

ylabel (‘Gain in dB’) ;

xlabel (‘Normalised Freq’) ;

title (‘Response of BPF using Hanning window’) ;

%Band pass filter

wn=[wp ws ] ;

b=firl (n,wn, ‘stop’, y) ;

[h,w]=freqz (b,1,512) ;

m=20*log(abs(h));

subplot (2,2,4)

plot(w/pi,m) ;

grid ;

ylabel (‘Gain in dB’) ;

xlabel (‘Normalised Freq’) ;

title (‘Response of BSF using Hanning window’) ;

RESULT :

Thus the program for FIR filters using various window are generated

and frequency response is plotted

Exp.No. 7

Date:

MULTIRATE FILTERS

AIM:

To program upsampling and down sampling of a signal using

MATLAB program.

SOFTWARE REQUIRED:

MATLAB Version 7.2

THEORY:

ALGORITHM:

Step1: Start the process

Step2: Enter the program for upsampling and downsampling in a

sequence

Step3: Run the program

Step4: Enter the length of the sequence that is to be upsampled and

downsampled.

Step5: Enter the number of sampling factor

Step6: Plot the output

PROGRAM:

A continuous time signal is characterized by the following equation

X(t)= A cos (2πf1t) + B Cos (2πf2t)

a) Generate with aid of Matlab a discrete time equivalent of the signal.

Assume a sampling frequency of 1KHz, f1= 50Hz, f2= 100 Hz and

the ratio of the amplitudes of the frequency components,(A/B) = 1.5

b) Interpolate the discrete time signal by a factor of 4.

c) Decimate the output of the interpolater in step (b) by a factor of 4

d) Plot the original, interpolated and decimated discrete time singals

MULTIRATE FILTERS

fs=1000; % sampling frequency

A=1.5; % relative amplitudes

B=1;

f1=50; % signal frequencies

f2=100;

t=0:1/fs:1; % time vector

x=A*cos(2*pi*f1*t)+B*cos(2*pi*f2*t); %generate signal

y=interp(x,4); %interpolate signal by 4

stem(x(1:25)) % plot original signal

xlabel('Discrete time, nT')

ylabel('Input signal level')

figure,

stem(y(1:100)) % plot interpolated signal

xlabel('Discrete time, 4 x nT')

ylabel('Interpolated output signal level')

figure,

y1=decimate(y,4);

stem(y1(1:25)) % plot decimated signal

xlabel('Discrete time, nT')

ylabel('Decimated output signal level')

RESULT:

Thus, a program for Multirate filters (upsampling and

downsampling)of a discrete time signal is performed and output is obtained.

Exp.No.8

Date:

ADAPTIVE FILTERS

AIM:

To design an Adaptive filter to identify an unknown 32 order FIR

filter using 500 iterations using MATLAB program.

SOFTWARE REQUIRED:

MATLAB Version 7.2

THEORY:

PROGRAM:

ADAPTIVE FILTER

Use 500 iterations of an adapting filter system to identify an unknown

32nd-order FIR filter.

x = randn(1,500); % Input to the filter

b = fir1(31,0.5); % FIR system to be identified

n = 0.1*randn(1,500); % Observation noise signal

d = filter(b,1,x)+n; % filter the signal through the

unknown system to get the

DESIRED SIGNAL.

mu = 0.008; % LMS step size.

ha = adaptfilt.lms(32,mu);

[y,e] = filter(ha,x,d); determine the unknown system.

subplot(3,1,1);plot(1:500,d);

title('Desired signal');

xlabel('Time Index'); ylabel('Signal Value');

subplot(3,1,2);plot(1:500,y);

title('Output signal');

xlabel('Time Index'); ylabel('Signal Value');

subplot(3,1,3);plot(1:500,e);

title('Error signal');

xlabel('Time Index'); ylabel('Signal Value');

figure,

subplot(2,1,1); plot(1:500,[d;y;e]);

title('System Identification of an FIR Filter');

legend('Desired','Output','Error');

xlabel('Time Index'); ylabel('Signal Value');

subplot(2,1,2); stem([b.',ha.coefficients.']);

legend('Actual','Estimated');

xlabel('Coefficient #'); ylabel('Coefficient Value');

grid on;

Result:

Thus an unknown FIR is identified using an adaptive filter system.

Exp.No.10

Date:

ECHO CANCELLATION

AIM:

To design a filter for noise cancellation.

SOFTWARE REQUIRED:

MATLAB Version 7.2

THEORY:

Noise or Interference Cancellation :

In noise cancellation, adaptive filters let you remove noise from a signal in

real time. Here, the desired signal, the one to clean up, combines noise and

desired information. To remove the noise, feed a signal n'(k) to the adaptive

filter that represents noise that is correlated to the noise to remove from the

desired signal. Using an Adaptive Filter to Remove Noise from an Unknown

System

So long as the input noise to the filter remains correlated to the unwanted

noise accompanying the desired signal, the adaptive filter adjusts its

coefficients to reduce the value of the difference between y(k) and d(k),

removing the noise and resulting in a clean signal in e(k). Notice that in this

application, the error signal actually converges to the input data signal,

rather than converging to zero.

S(K)+n(k)

n^(k)

+

Adaptive

Filter

ADAPTIVE FILTER

Design an Adaptive RLS filter to extract useful information from a noisy

signal. The information bearing signal is a sine wave of 0.055

cycles/sample,that is corrupted by additive white gaussian noise.

Assume the use of two microphones for this adaptive noise

cancellation system with the noisy input signal as the input to a primary

microphone, while a secondary microphone receives noise that is

uncorrelated to the information bearing signal, but is correlated to the noise

picked up by the primary microphone. The noise that corrupts the sine wave

is a lowpass filtered version of (correlated to) the noise picked up by the

secondary microphone.

%The information bearing signal is a sine wave of 0.055 cycles/sample.

signal = sin(2*pi*0.055*(0:1000-1)');

subplot(3,1,1),plot(0:199,signal(1:200));

grid; axis([0 200 -2 2]);

title('The information bearing signal');

%The noise picked up by the secondary microphone is the input for the RLS

adaptive filter.The noise that corrupts the sine wave is a lowpass filtered

version of (correlated to) this noise.The sum of the filtered noise and the

information bearing signal is the desired signal for the adaptive filter.

nvar = 1.0; % Noise variance

noise = randn(1000,1)*nvar; % White noise

subplot(3,1,2),plot(0:999,noise);

title('Noise picked up by the secondary microphone');

grid; axis([0 1000 -4 4]);

%The noise corrupting the information bearing signal is a filtered version of

'noise':

nfilt = fir1(31,0.5); % 31st order Low pass FIR filter

fnoise = filter(nfilt,1,noise); % Filtering the noise

%"Desired signal" for the adaptive filter (sine wave + filtered noise):

d = signal+fnoise;

subplot(3,1,3),plot(0:199,d(1:200));

grid; axis([0 200 -4 4]);

title('Desired input to the Adaptive Filter = Signal + Filtered Noise');

%Set and initialize RLS adaptive filter parameters and values:

M = 32; % Filter order

lam = 1; % Exponential weighting factor

delta = 0.1; % Initial input covariance estimate

w0 = zeros(M,1); % Initial tap weight vector

P0 = (1/delta)*eye(M,M); % Initial setting for the P matrix

Zi = zeros(M-1,1); % FIR filter initial states

%Running the RLS adaptive filter for 1000 iterations. The plot shows the

convergence of the adaptive filter response to the response of the FIR filter.

Hadapt = adaptfilt.rls(M,lam,P0,w0,Zi);

Hadapt.PersistentMemory = true;

[y,e] = filter(Hadapt,noise,d);

H = abs(freqz(Hadapt,1,64));

H1 = abs(freqz(nfilt,1,64));

wf = linspace(0,1,64);

figure,

plot(wf,H,wf,H1);

xlabel('Normalized Frequency (\times\pi rad/sample)');

ylabel('Magnitude');

legend('Adaptive Filter Response','Required Filter Response');

grid;

axis([0 1 0 2]);

%As the adaptive filter converges, the filtered noise should be completely

subtracted from the "signal + noise" signal and the error signal 'e' should

contain only the original signal.

figure,plot(0:499,signal(1:500),0:499,e(1:500)); grid;

axis([0 500 -4 4]);

title('Original information bearing signal and the error signal');

legend('Original Signal','Error Signal');

RESULT:

Thus an Adaptive filter has been designed for noise or interference

rejection from information bearing signal.

Exp.No :9

Date:

EQUALIZATION

AIM:

To Demonstrate and perform equalization using Mat lab program

SOFTWARE REQUIRED:

MATLAB Version 7.2

THEORY:

EQUALIZATION

Time-dispersive channels can cause intersymbol interference (ISI).

For example, in a multipath scattering environment, the receiver sees

delayed versions of a symbol transmission, which can interfere with other

symbol transmissions.An equalizer attempts to mitigate ISI and thus

improve the receiver's performance.

Channel equalization is a simple way of mitigating the detrimental

effects caused by a frequency-selective and/or dispersive communication

link between sender and receiver. For this demonstration, all signals are

assumed to have a digital baseband representation.During the training phase

of channel equalization, a digital signal s[n] that is known to both the

transmitter and receiver is sent by the transmitter to the receiver. The

received signal x[n] contains two signals:the signal s[n] filtered by the

channel impulse response,and an unknown broadband noise signal v[n]. The

goal is to filter x[n] to remove the inter-symbol interference (ISI) caused by

the dispersive channel and to minimize the effect of the additive noise

v[n].Ideally, the output signal would closely follow a delayed version of the

transmitted signal s[n].

EQUALIZATION USING MATLAB :

Equalizing a signal using Communications Toolbox involves these steps:

>> Create an equalizer object that describes the equalizer class and the

adaptive algorithm that you want to use. An equalizer object is a type of

MATLAB variable that contains information about the equalizer, such

as the name of the equalizer class, the name of the adaptive algorithm, and

the values of the weights.

>> Adjust properties of the equalizer object, if necessary, to tailor it to your

needs. For example, you can change the number of weights or the values of

the weights.

>> Apply the equalizer object to the signal you want to equalize, using the

equalize method of the equalizer object.

PROGRAM:

Design an equalizer of the type shown in figure given below. H(z) represents

a communication channel with the following numerator and denominator

coefficients respectively : b = exp(j*pi/5)*[0.2 0.7 0.9];

a = [1 -0.7 0.4].Write a MATLAB script that uses

a RLS algorithm based adaptive filter to construct an equalizer of order

l=20.Use RLS forgetting factor lambda = 0.99.

The input signal takes one of sixteen different values given by all possible

combinations of {-3, -1, 1, 3} + j*{-3, -1, 1, 3}, where j = sqrt(-1).Generate

a sequence of 5000 such symbols, where each one is

equiprobable. Assume a complex Gaussian noise signal for the additive

noise. And use only the first 2000 samples for training.

%TRANSMITTED INPUT SIGNAL

%[The input signal takes one of sixteen different values given by all possible

combinations of {-3, -1, 1, 3} + j*{-3, -1, 1, 3}, where j = sqrt(-1).Let's

generate a sequence of 5000 such symbols, where each one is

equiprobable.]

ntr = 5000;

j = sqrt(-1);

s = sign(randn(1,ntr)).*(2+sign(randn(1,ntr)))+...

j*sign(randn(1,ntr)).*(2+sign(randn(1,ntr)));

plot(s,'o');

axis([-4 4 -4 4]);

axis('square');

+

Delay

Z

-m

Unknown

System , H(z)

Adaptive

Filter, W(z)

xlabel('Re\{s(n)\}');

ylabel('Im\{s(n)\}');

title('Input signal constellation');

%TRANSMISSION CHANNEL

%[The transmission channel is defined by the channel impulse response and

the noise characteristics.]

b = exp(j*pi/5)*[0.2 0.7 0.9];

a = [1 -0.7 0.4];

% Transmission channel filter

channel = dfilt.df2t(b,a);

% Impulse response

hFV = fvtool(channel,'Analysis','impulse');

legend(hFV, 'Transmission channel');

set(hFV, 'Color', [1 1 1])

%------------------------------------------------

%RECEIVED SIGNAL

%[The received signal x[n] is generated by the transmitted signal s[n]

filtered by the channel impulse response with additive noise v[n]. We shall

assume a complex Gaussian noise signal for the additive noise.]

sig = sqrt(1/16*(4*18+8*10+4*2))/sqrt(1000)*norm(impz(channel));

v = sig*(randn(1,ntr) + j*randn(1,ntr))/sqrt(2);

x = filter(channel,s) + v;

figure,plot(x,'.');

xlabel('Re\{x[n]\}');

ylabel('Im\{x[n]\}');

axis([-40 40 -40 40]);

axis('square');

title('Received signal x[n]');

set(gcf, 'Color', [1 1 1])

%-------------------------------------------------

%TRAINING SIGNAL

%[The training signal is a shifted version of the original transmitted signal

s[n].This signal would be known to both the transmitter and receiver.]

d = [zeros(1,10) s(1:ntr-10)];

%--------------------------------------------------

%TRAINED EQUALIZATION

%[To obtain the fastest convergence, we shall use the conventional version

of a recursive least-squares estimator. Only the first 2000 samples are used

for training. The output signal constellation shows clusters of values

centered on the sixteen different symbol values--an indication that

equalization has been achieved.]

P0 = 100*eye(20);

lam = 0.99;

h = adaptfilt.rls(20,lam,P0);

ntrain = 1:2000;

[y,e] = filter(h,x(ntrain),d(ntrain));

figure,plot(y(1001:2000),'.');

xlabel('Re\{y[n]\}');

ylabel('Im\{y[n]\}');

axis([-5 5 -5 5]);

axis('square');

title('Equalized signal y[n]');

set(gcf, 'Color', [1 1 1])

RESULT:

Thus Equalization is performed using Matlab and output is verified

Exp.No.10

Date:

SAMPLING AND ALIASING

AIM:

To a sample of continuous time signal and to show the effect of

aliasing.

SOFTWARE REQUIRED:

MATLAB version 7.2

THEORY:

Sampling is the acquisition of Act waves as a discrete time interval

and is a fundamental concept in a real time signal processing.

SAMPLING THEOREM:

If the highest frequency component in a signal in junction is unknown,

then the signal should be sampled at a rate of atleast 2 tmax for the samples

to describe the signal completely. When F is sampling freqeuncy or rate.

Thus if f max is an analog signal 4KHZ, then the signal should be sampled

at 8 KHZ or more.

The superimposition of high frequency component on low frequency

is called aliasing.

ALGORITHM:

Step 1: Start the process

Step 2: Calculate sampling frequency and sampling time

for fs > 2wm,

f = 2wm, f < 2wm

Step 3: Plot the graph

Step 4: Observe aliasing effect

Step 5: Store the result

Step 6: Stop the process

PROGRAM:

SAMPLING AND ALIASING

clc;

clear all ;

close all ;

fm=input (‘enter the signal frequency, fm = ‘) ;

t=[0 : . 02 : 1 ] ;

x=cos 92*pi*fm*t) ;

ts1 = .2 ;

ts2 = .1 ;

ts3 = .04 ;

t1 = [0 : ts1 : 1] :

x1 = cos (2*pi*t1*fm) ;

subplot (2,2,1) ;

plot (t,x)

xlabel (‘time’) ;

ylabel (‘x(t)’) ;

title (‘inputsignal’) ;

subplot (2,2,2) ;

stem (t1, x1) ;

xlabel (‘n’) ;

ylabel (‘x(n)’) ;

title (‘sampled sequence with fs<2fm’) ;

hold on ;

plot (t,x,’r : ‘ ) ;

hold off ;

t2=[0 : ts2 : 1] ;

x2=cos(2*pi*t2*fm) ;

subplot(2,2,3)

stem(t2,x2) ;

xlabel (‘n’) ;

ylabel (‘x(n)’) ;

title (‘sampled sequence with fs=2fm’) ;

hold on ;

plot (t,x,’r’:’) ;

hold off

t3=[0 :ts3 : 1] ;

x3=cos(2*pi*t3*fm) ;

subplot (2,2,4)

stem(t3,x3) ;

xlabel (‘n’) ;

ylabel (‘x(n)’) ;

hold on ;

plot (t,x,’r’:’) ;

hold off

title (‘sampling sequence with fs=2fm’) ;

gtext(‘sampling &* effect of aliasing’ ) ;

RESULT

Thus a simple program for sampling and aliasing was written and

output has been obtained successfully.

d

d

- A Design Technique for Analog Active Filters
- 00951a
- V2I500482
- Chapt 7
- Audio Equalizer in Matlab.ppt
- Matlab Tutorial
- Digital Signal Processing-chapter 16
- RELP
- Dtmf Report
- Wireless Audio Signal Transmission
- Program
- IV B.E. (Bio-Medical Engineering)
- Gf 3511031106
- DSP Final Paper
- Interpolator Control
- LEM DX 26 plus- 2 in / 6 out digital loudspeaker management processor
- 89762720 Manual de Ejercicios Multisim
- Agilent 33250-90011 Service Guide
- --1365767395-11.Electrical - IJEEER -Ber perforamnce - HARJOT KAUR.pdf
- Wavetek Cli 1450 Op Man
- SystemModel_AD9361
- MULTI H
- 081_Polak
- VLSI Implementation Ofdm
- pllthesis
- FPGA-Based Bit Error Rate Performance Measurement of Wireless Systems
- VBLAST
- 047084356X
- JESD204B-Survival-Guide.pdf
- 9

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

We've moved you to where you read on your other device.

Get the full title to continue

Get the full title to continue listening from where you left off, or restart the preview.

scribd