Circular Convolution Method 1 | Scigyan

Circular Convolution Method 1

Matlab program to find Circular Convolution using fft and ifft predefined function.
Circular Convolution: If x(n) is a sequence of N1 number of samples and h(n) with N2 samples, after convolution y(n) will have N=max(N1,N2) samples.
It cannot be used to find the response of a filter. Zero padding is necessary to find the response of a filter.
Two another methods of Circular Convolution: By matrix multiplication and By using for loop function.

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;

X=fft(x,N);
H=fft(h,N); Y=X.*H;
y=ifft(Y,N);
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-1
No comments:
Post a Comment

Related Posts Plugin for WordPress, Blogger...