Circular Convolution Method 3 | Scigyan

Circular Convolution Method 3

Matlab program to find Circular Convolution by using for loop function.
Two another methods of Circular Convolution:  Using fft and ifft predefined function and By matrix multiplication.

Matlab code

clc;
close all; clear all;
x=input('Enter the 1st sequence x[n] = '); 
h=input('Enter the 2nd sequence h[n] = ');
N1=length(x);
N2=length(h);
N=max(N1,N2); %Length of Circular convolved output sequence
if(N1>N2)
h=[h,zeros(1,N1-N2)]; %Modified second sequence if N1>N2
else
x=[x,zeros(1,N2-N1)]; %Modified first sequence if N1
end;
for n=1:N; y(n)=0;
for i=1:N; j=n-i+1; if(j<=0)
j=N+j;
end; y(n)=y(n)+x(i)*h(j);
end; end;
disp('Circular convolved output y[n ] =');y %To view output in command window

%To display and plot circular convolution
subplot(3,1,1);
stem(0:N-1,x);
xlabel('N-->');
ylabel('Amplitude-->'); title('1st input sequence x[n] ');
subplot(3,1,2);
stem(0:N-1,h);
xlabel('N-->');
ylabel('Amplitude-->'); title('2nd input sequence h[n]');

subplot(3,1,3);
stem(0:N-1,y);
xlabel('N-->');
ylabel('Amplitude-->');
title('Circular convolved output y[n]');

Command window

Enter the 1st sequence x[n] = [1 2 3 4]
Enter the 2nd sequence h[n] = [3 5 2 1]
Circular convolved output y[n ]  =
y =
    31    22    25    32

Figure window

Circular-Convolution-Method-3
No comments:
Post a Comment

Related Posts Plugin for WordPress, Blogger...