Blogger Widgets
Showing posts with label Signal_DSP Labs. Show all posts
Showing posts with label Signal_DSP Labs. Show all posts

Monday, 30 April 2012

Circular Convolution of two Sequences

MATLAB CODE:-
clc
close all
clear all
x=input('Enter the sequence x:');
h=input('Enter the sequence h:');
subplot(3,1,1);
stem(x);
xlabel('--->n');
ylabel('Amp');
legend('Input Sequence');


subplot(3,1,2);
stem(h);
xlabel('--->');
ylabel('Amp');
legend('Impulse Responce');

lx=length(x);
lh=length(h);
l=max(lx,lh);
x=[x,zeros(1,l-lx)];
h=[h,zeros(1,l-lh)];
H=zeros(l,l);
H(1:lh,1)=h;
for j=1:l-1
    for i=1:l-1
        H(i+1,j+1)=H(i,j);
    end
        H(1,j+1)=H(l,j);
end
y=H*x';
subplot(3,1,3);
stem(y);
title('Circular Convulation');

INPUT & OUTPUT:-
Enter the sequence x:[1 -1 2 3]
Enter the sequence h:[1 -2 3 1]
>> y

y =

     0
     8
    10
    -3

FIGURE:-


Continue Reading »

DFT & IDFT Using Twiddle Factor

MATLAB CODE:
clc
close all
clear all
X=input('Enter the sequence :');
L=input('Enter the length:');
lx=length(X);
x1=[X,zeros(1,L-lx)];
w=(-1j*2*pi/L);
subplot(5,1,1);
stem(X);
legend('Input Sequences');

for n=0:L-1;
    for k=0:L-1;
        w1(n+1,k+1)=w^(n*k);
    end
end
DFTX=x1*w1;
subplot(5,1,2);
stem(abs(DFTX));
legend('amplitude plot of DFT');
subplot(5,1,3);
stem(angle(DFTX));
legend('phase plot of DFT');

W2=(j*2*pi/L);
for n=0:L-1;
    for k=0:L-1;
        w3(n+1,k+1)=w^(n*k);
    end
end

IDFTX=(DFTX*w3)/L;
subplot(5,1,4);
stem(abs(IDFTX));
legend('Amplitude plot for IDFT');
subplot(5,1,5);
stem(angle(IDFTX));
legend('Phase plot for IDFT');
Input:
enter the sequence: [1 2 3 4]
enter the length: 4


Figure:-
Continue Reading »