Wednesday, 2 January 2013

MATLAB CODE FOR CIRCULAR CONVOLUTION

MATLAB CODE FOR CIRCULAR CONVOLUTION



The circular convolution, also known as cyclic convolution, of two aperiodic functions occurs when one of them is convolved in the normal way with a periodic summation of the other function.  That situation arises in the context of the Circular convolution theorem.  The identical operation can also be expressed in terms of the periodic summations of both functions, if the infinite integration interval is reduced to just one period.  That situation arises in the context of the discrete-time Fourier transform (DTFT) and is also called periodic convolution.  In particular, the transform (DTFT) of the product of two discrete sequences is the periodic convolution of the transforms of the individual sequences.






                                     
\begin{align}
(x_T * h)(t)\quad &\stackrel{\mathrm{def}}{=} \ \int_{-\infty}^\infty h(\tau)\cdot x_T(t - \tau)\,d\tau \\
&= \int_{t_o}^{t_o+T} h_T(\tau)\cdot x_T(t - \tau)\,d\tau,
\end{align}
CODE:
clc;
disp('Input :');
x=input('Enter the first sequence : ');
h=input('Enter the second sequence : ');
N1=length(x);
N2=length(h);
N=8;
x=[x zeros(1,N‐N1)];
h=[h zeros(1,N‐N2)];
M=[0:1:N‐1];
disp(M);
h=h(M+1);
disp(h);
M=mod(‐M,N);
disp(M);
for n=1:1:N
            M=n‐1;
            p=0:1:N‐1;
            q=mod(p‐M,N);
            disp(q);
            hm=h(q+1);
            H(n,:)=hm;
            disp(H(n,:));
end
y=x*H;

%plot;
n1=0:1:N‐1;
subplot(3,1,1);
stem(n1,x);
title('First sequence');
xlabel('Sample...');
ylabel('Magnitude...');

subplot(3,1,2);
stem(n1,h);
title('Second sequence');
xlabel('Sample...');
ylabel('Magnitude...');

subplot(3,1,3);
stem(n1,y);
disp('The output is y= ');
disp(y);
title('Circular Convolution');
xlabel('Sample...');
ylabel('Magnitude…’);

OUTPUT:
        Enter the first sequence : [1 2 3 4]
        Enter the second sequence : [1 0 1 0 1]
        The output is y=
                 1 2 4 6 4 6 3 4




6 comments:

  1. not running properly in matlab

    ReplyDelete
    Replies
    1. Circular convolution is one of the fundamental operations in Digital Signal Processing and plays an important role in communication systems, filtering, spectral analysis, and multimedia applications. Students working on Final Year Projects for ECE can gain valuable practical experience by implementing DSP algorithms using simulation tools such as MATLAB and applying them to real-world signal processing problems.

      The article also demonstrates how mathematical modeling and software-based simulations simplify the understanding of complex engineering concepts. Exploring Final Year Project Domains for ECE can help students discover advanced areas such as Digital Signal Processing, Communication Systems, Image Processing, and Embedded Systems, where these techniques are extensively applied.

      Delete
  2. its work only for a fixed 5 element and 4 element sequence, if we use some two other sequence this program will not work. :-|

    ReplyDelete

Search Here...