10:33 AM
To develop program for linear convolution and correlation using MATLAB

ALGORITHM:

1. Enter the input Sequence ,x having length=4

2. Enter the Impulse Sequence, h having length=4

3. Performing the Convolution, store the value in y

4. Plotting the Input Sequence.

5. Plotting the Impulse Sequence.

6. Plotting the Output Sequence.


PROGRAM:

%linear convolution program

clc;

clear all;

close all;

disp('linear convolution program');

x=input('enter i/p x(n):');

m=length(x);

disp(m);

h=input('enter i/p h(n):');

n=length(h);

disp(n);

x=[x,zeros(1,n)];

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

title('i/p sequence x(n)is:');

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

ylabel('---->x(n)');grid;

h=[h,zeros(1,m)];

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

title('i/p sequence h(n)is:');

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

ylabel('---->h(n)');grid;

disp('convolution of x(n) & h(n) is y(n):');

y=zeros(1,m+n-1);

for i=1:m+n-1

y(i)=0;

for j=1:m+n-1

if(j<i+1)

y(i)=y(i)+x(j)*h(i-j+1);

end

end

end

subplot(2,2,[3,4]),stem(y);

title('convolution of x(n) & h(n) is :');

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

ylabel('---->y(n)');grid;

disp(y);
 

%program for discrete Correlation
 

x=[1 2 3 4];

y=[2 3 4 5];

z=xcorr(x,y);

stem(z);

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

title(‘input sequence 1’)

subplot(2,2,2),stem(y)

title(‘input sequence 2’)

subplot(2,2,3),stem(z)

title(‘output sequence’)

Views: 101 | Added by: vijoriya | Tags: program, linear convolution, correlation, MatLab | Rating: 0.0/0
Total comments: 0
avatar