Skip to main content

DFT Circular Convolution by Overlap Add Method in Matlab

 

Matlab Code:

     clc;

close all;

x=input('Enter the input sequence: ');

h=input('Enter the impulse sequence: ');

n=length(x);

m=length(h);

z=1;

for i=1:4

    if i~=4

        for j=1:m

            X(i,j)=x(((i-1)*m)+1+(j-1));

        end

        for j=m+1:5

            X(i,j)=0;

        end

    else

        for j=1:5

            if j==1

                X(i,j)=x(n);

            else

                X(i,j)=0;

            end

        end

    end

end

disp('Subsets of sequense: ');

disp(X);

 

y1=cconv(X(1,1:5),h,5);

y2=cconv(X(2,1:5),h,5);

y3=cconv(X(3,1:5),h,5);

y4=cconv(X(4,1:5),h,5);

 

Y=[y1(1:m),y1(m+1:end)+y2(1:m-1),y2(m),y2(m+1:end)+y3(1:m-1),y3(m),y3(m+1:end)+y4(1:m-1),y4(m:end)];

Y=Y(1:n+m-1); 

disp('By Overlap Add Method: ');

disp(Y);


Output:

Enter the input sequence: [3 -1 0 1 3 2 0 1 2 1]

Enter the impulse sequence: [1 1 1]

Subsets of sequence:

     3    -1     0     0     0

     1     3     2     0     0

     0     1     2     0     0

     1     0     0     0     0

 

By Overlap Add Method:

    3.0000    2.0000    2.0000    0.0000    4.0000    6.0000    5.0000    3.0000    3.0000    4.0000    3.0000    1.0000

Comments

Popular posts from this blog

Matlab Code to obtain DFT and plot its magnitude and phase response

Matlab Code:-   clc; clear all; close all; x=input('Enter the sequence: '); N=length(x); Wn=exp((-j*2*pi)/N);%Twiddle factor fprintf('Twiddle Factor=%f+j(%f)\n',real(Wn),imag(Wn)); disp('Magnitude and phase of Twiddle Factor:');     fprintf('|Wn|=%f    ',Wn);     fprintf('angle Wn=%f\n', angle(Wn));  fprintf('\n');  for k=1:N     X(k)=0; end %Calculation of DFT for k=1:N     for n=1:N         X(k)=X(k)+(x(n)*Wn^((k-1)*(n-1)));     end end %Printing the DFT fprintf('DFT of x(n) is:\n'); disp(X); fprintf('\n'); fprintf('X(k)\tMagnitude\tPhase\n\n'); for k=1:N     fprintf('X(%d)\t%f\t%f\n',k-1,X(k),angle(X(k))); end %To plot the magnitude and phase of the DFT subplot(1,2,1); stem(X,'linewidth',1.5); xlabel('k--->'); ylabel('magnitude--->'); title('Magnitude Response'); grid on; subplot(1,2,2); stem(angle(X),'linewidth',1.5); xlabel('k--->'); ylabel('...

PN Sequence Generator Circuit Design in Multisim

 I tried doing a PN Sequence generator using a shift register in Multisim but it didn't work. However this one with d flip flops and xor gate did work somewhat. Here is the circuit.       Components Required:      1. 4D Flip Flops      2. XOR Gate      3. Function Generator for Clock Pulses      4. Oscilloscope       Circuit Design  :        Output:- Red Square waves- Clock Pulses Blue waves- PN sequence Hope this helps!

How to plot a Continuous Time Sequence and Discrete Time Sequence in Matlab

1. For Continuous Time Sequence:        Use the function:  plot(X-axis, Y-axis)          For example to plot a parabolic function p(t)=  At^2 for t>=0                                                                                    0        for t<0           Code:           %UNIT PARABOLIC FUNCTION t=linspace(-20,20,20);      %range of X-asis A=1;                  %amplitude of the function for A=1 it is called unit parabolic function p=[t>=0].*(A.*t.^2)/2;      %parabola equation as defined above subplot(1,2,1);                ...