Sunday, January 26, 2014

Matlab Program for Linear Convolution

with 0 Comment
Matlab Program for Linear Convolution:

Program 1: ( Program assigned Input )

clc
close all
clear all
x=[1 2 3 4]
subplot(2,2,1);
stem(x);
title('x(n) sequence');
xlabel('n');
ylabel('Amplitude');
grid on

h=[1 2 1 2];
subplot(2,2,2);
stem(h);
title('h(n) sequence');
xlabel('n');
ylabel('Amplitude');
grid on

y=conv(x,h);
subplot(2,2,3);
stem(y);
grid on
title('y(n) sequence');
xlabel('n');
ylabel('Amplitude');

Program 2: ( User Assigned Input )

clc
clear
x=input('Enter the x(n) sequence');
c=length(x);
t=0:c-1;
subplot(2,2,1);
stem(t,x);
title('x(n) Sequence');
xlabel('n');
ylabel('x(n)');

h=input('Enter the h(n) sequence');
c=length(h);
t=0:c-1;
subplot(2,2,2);
stem(t,h);
title('h(n) Sequence');
xlabel('n');
ylabel('h(n)');

y=conv(x,h);
c=length(y);
t=0:c-1;
subplot(2,2,3);
stem(t,y);
disp('The y(n)Convolution sequence is');
disp(y);
title('Linear Convolution');
xlabel('n');
ylabel('y(n)');

0 comments:

Post a Comment

Powered by Blogger.

Blog Archive