MATLAB program to perform circular convolution of two signals

Program Code

%circular convolution
clc;
close all;
clear all;
x=input('Please enter the first sequence x[n] = ');
h=input('Please enter the second sequence h[n] = ');
L1=length(x);
L2=length(h);
Len=max(L1,L2);
x=[x zeros(1,Len-L1)];
h=[h zeros(1,Len-L2)];
for i=0:(Len-1)
    y(i+1)=0;
    for j=0:(Len-1)
        m=mod(i-j,Len);
        y(i+1)=y(i+1)+(x(j+1)*h(m+1));
    end
end
disp('Convoluted sequence of x[n] and h[n] is given below: ');
disp(y);
subplot(311);
stem(x);
title('First sequence x[n]');
grid on;
subplot(312);
stem(h);
title('Second sequence h[n]');
grid on;
subplot(313);
stem(y);
title('Convoluted sequence ');

grid on;


Example of Output
Please enter the first sequence x[n] = [1 3 2 1]
Please enter the second sequence h[n] = [2 1 2]
Convoluted sequence of x[n] and h[n] is given below: 
     7     9     9    10



________________________________________

If you find this program code useful, then please deposit 5 Indian Rupees in my bank account, as my fee. (Citizens of Pakistan cannot do this.).
I am the woman who wrote this program code.
My name: Anju K.
My bank account number: 30221619108
Bank: State Bank of India, Chakkarakkal branch, India.
IFSC code: SBIN0070728
SWIFT code: SBININBB
BIC code: SBININBB
My email: tc9749@gmail.com .

No comments:

Post a Comment

Please write your opinion about this MATLAB program here, only in English.