Implementation of Decimation / Interpolation Process with Waveforms
clc;
clear all;
close all;
t=0:0.01:1;
d=input('enter number D/I');
x=sin(2*pi*5*t);
y=decimate(x,d);
subplot(3,1,1);
stem(x(1:25));
title('original input signal');
xlabel('samples');
ylabel('amplitude');
subplot(3,1,2);
stem(y);
title('decimated output');
xlabel('samples');
ylabel('amplitude');
y1=interp(y,d);
subplot(3,1,3);
stem(y1(1:25));
title('interpolation output');
xlabel('samples');
ylabel('amplitude');
clear all;
close all;
t=0:0.01:1;
d=input('enter number D/I');
x=sin(2*pi*5*t);
y=decimate(x,d);
subplot(3,1,1);
stem(x(1:25));
title('original input signal');
xlabel('samples');
ylabel('amplitude');
subplot(3,1,2);
stem(y);
title('decimated output');
xlabel('samples');
ylabel('amplitude');
y1=interp(y,d);
subplot(3,1,3);
stem(y1(1:25));
title('interpolation output');
xlabel('samples');
ylabel('amplitude');
Implementation of Decimation Process with Waveforms
clc;
clear all;
close all;
x=input('enter the sequence');
d=input('enter the decimation factor');
N=length(x);
n=0:N-1;
xd=x(1:d:N);
n1=1:N/d;
subplot(2,1,1);
stem(n,x);
title('input signal');
xlabel('samples');
ylabel('amplitude');
subplot(2,1,2);
stem(n1-1,xd);
title('decimated output');
xlabel('samples');
ylabel('amplitude');
clear all;
close all;
x=input('enter the sequence');
d=input('enter the decimation factor');
N=length(x);
n=0:N-1;
xd=x(1:d:N);
n1=1:N/d;
subplot(2,1,1);
stem(n,x);
title('input signal');
xlabel('samples');
ylabel('amplitude');
subplot(2,1,2);
stem(n1-1,xd);
title('decimated output');
xlabel('samples');
ylabel('amplitude');
FFT and Convolution for FFT with Waveforms
clc;
clear all;
close all;
x=input('enter the sequence');
N=input('enter the number of smples');
n=0:N-1
y=fft(x,N);
y1=abs(y);
y2=angle(y);
y3=ifft(y);
figure(1);
subplot(2,1,1);
stem(x);
title('original signal');
xlabel('samples');
ylabel('amplitude');
subplot(2,1,2);
stem(y);
title('fft signal');
xlabel('samples');
ylabel('amplitude');
figure(2);
subplot(2,1,1);
stem(y1);
title('magnitude plot');
xlabel('samples');
ylabel('amplitude');
subplot(2,1,2);
stem(y2);
title('phase angle');
xlabel('samples');
ylabel('amplitude');
figure(3);
subplot(2,1,1);
stem(y);
title('frequency domain sequence');
xlabel('samples');
ylabel('amplitude');
subplot(2,1,2);
stem(y3);
title('invers fft signal');
xlabel('samples');
ylabel('amplitude');
% CONV FOR FFT
clc;
clear all;
close all;
x=input('enter sequence of x');
h=input('enter sequence of h');
X1=[x zeros(1,length(h)-1)];
disp('X1=');
disp(X1);
h1=[h zeros(1,length(x)-1)];
disp('h1=');
disp(h1);
X=fft(x1);
H=fft(h1);
y=X.*H;
y1=ifft(y);
disp('the conv y1=');
disp(y1);
figure(1);
subplot(5,1,1);
stem(x);
title('input signal 1');
xlabel('samples');
ylabel('amplitude');
subplot(5,1,2);
stem(h);
title('input signal 2');
xlabel('samples');
ylabel('amplitude');
subplot(5,1,3);
stem(X1);
title('fft signal 1');
xlabel('samples');
ylabel('amplitude');
subplot(5,1,4);
stem(h1);
title('fft signal 2');
xlabel('samples');
ylabel('amplitude');
subplot(5,1,5);
stem(y1);
title('conv signal');
xlabel('samples');
ylabel('amplitude');
clear all;
close all;
x=input('enter the sequence');
N=input('enter the number of smples');
n=0:N-1
y=fft(x,N);
y1=abs(y);
y2=angle(y);
y3=ifft(y);
figure(1);
subplot(2,1,1);
stem(x);
title('original signal');
xlabel('samples');
ylabel('amplitude');
subplot(2,1,2);
stem(y);
title('fft signal');
xlabel('samples');
ylabel('amplitude');
figure(2);
subplot(2,1,1);
stem(y1);
title('magnitude plot');
xlabel('samples');
ylabel('amplitude');
subplot(2,1,2);
stem(y2);
title('phase angle');
xlabel('samples');
ylabel('amplitude');
figure(3);
subplot(2,1,1);
stem(y);
title('frequency domain sequence');
xlabel('samples');
ylabel('amplitude');
subplot(2,1,2);
stem(y3);
title('invers fft signal');
xlabel('samples');
ylabel('amplitude');
% CONV FOR FFT
clc;
clear all;
close all;
x=input('enter sequence of x');
h=input('enter sequence of h');
X1=[x zeros(1,length(h)-1)];
disp('X1=');
disp(X1);
h1=[h zeros(1,length(x)-1)];
disp('h1=');
disp(h1);
X=fft(x1);
H=fft(h1);
y=X.*H;
y1=ifft(y);
disp('the conv y1=');
disp(y1);
figure(1);
subplot(5,1,1);
stem(x);
title('input signal 1');
xlabel('samples');
ylabel('amplitude');
subplot(5,1,2);
stem(h);
title('input signal 2');
xlabel('samples');
ylabel('amplitude');
subplot(5,1,3);
stem(X1);
title('fft signal 1');
xlabel('samples');
ylabel('amplitude');
subplot(5,1,4);
stem(h1);
title('fft signal 2');
xlabel('samples');
ylabel('amplitude');
subplot(5,1,5);
stem(y1);
title('conv signal');
xlabel('samples');
ylabel('amplitude');
DFT and IDFT with Wave Forms
clc;
clear all;
close all;
x=input('enter the input sequence');
L=length(x);
N=input('enter number of samples');
xn=[x zeros(1,N-L)]
n=[0:1:N-1]
k=[0:1:N-1]
wN=exp(-j*2*pi/N);
nk=n'*k;
wNnk=wN.^(nk);
xk=xn*wNnk;
disp('dft of given sequence');
disp(xk);
figure(1);
subplot(2,1,1);
stem(k,xn);
title('original samples');
xlabel('samples');
ylabel('amplitude');
subplot(2,1,2);
stem(k,xk);
title('discrete fourier transform');
xlabel('samples');
ylabel('amplitude');
figure(2)
subplot(2,1,1);
stem(k,abs(xk));
title('magnitude response');
xlabel('samples');
ylabel('amplitude');
subplot(2,1,2);
stem(k,angle(xk));
title('phase response');
xlabel('frequency');
ylabel('amplitude');
% IDFT
clc;
clear all;
close all;
x=input('enter the input sequence');
L=length(x);
N=input('enter number of samples');
xk=[x zeros(1,N-L)]
n=[0:1:N-1]
k=[0:1:N-1]
wN=exp(-j*2*pi/N);
nk=n'*k;
wNnk=wN.^(-nk);
xn=(xk*wNnk)/N;
disp('dft of given sequence');
disp(xk);
figure(1);
subplot(2,1,1);
stem(k,xk);
title('original samples');
xlabel('samples');
ylabel('amplitude');
subplot(2,1,2);
stem(k,xn);
title('discrete fourier transform');
xlabel('samples');
ylabel('amplitude');
clear all;
close all;
x=input('enter the input sequence');
L=length(x);
N=input('enter number of samples');
xn=[x zeros(1,N-L)]
n=[0:1:N-1]
k=[0:1:N-1]
wN=exp(-j*2*pi/N);
nk=n'*k;
wNnk=wN.^(nk);
xk=xn*wNnk;
disp('dft of given sequence');
disp(xk);
figure(1);
subplot(2,1,1);
stem(k,xn);
title('original samples');
xlabel('samples');
ylabel('amplitude');
subplot(2,1,2);
stem(k,xk);
title('discrete fourier transform');
xlabel('samples');
ylabel('amplitude');
figure(2)
subplot(2,1,1);
stem(k,abs(xk));
title('magnitude response');
xlabel('samples');
ylabel('amplitude');
subplot(2,1,2);
stem(k,angle(xk));
title('phase response');
xlabel('frequency');
ylabel('amplitude');
% IDFT
clc;
clear all;
close all;
x=input('enter the input sequence');
L=length(x);
N=input('enter number of samples');
xk=[x zeros(1,N-L)]
n=[0:1:N-1]
k=[0:1:N-1]
wN=exp(-j*2*pi/N);
nk=n'*k;
wNnk=wN.^(-nk);
xn=(xk*wNnk)/N;
disp('dft of given sequence');
disp(xk);
figure(1);
subplot(2,1,1);
stem(k,xk);
title('original samples');
xlabel('samples');
ylabel('amplitude');
subplot(2,1,2);
stem(k,xn);
title('discrete fourier transform');
xlabel('samples');
ylabel('amplitude');
Frequency Response of a Given System with Wave Forms
%impulse response
clc;
clear all;
close all;
N=input('enter the length of the sequence');
a=input('enter the numerator coefficient value');
b=input('enter the denominator coefficient value');
n1=0:1:N-1;
x1=(n1==0);
h1=filter(b,a,x1);
disp(h1);
subplot(2,1,1);
stem(n1,x1);
title('impulse response');
xlabel('samples');
ylabel('amplitude');
subplot(2,1,2);
stem(n1,h1);
xlabel('samples');
ylabel('amplitude');
clc;
clear all;
close all;
N=input('enter the length of the sequence');
a=input('enter the numerator coefficient value');
b=input('enter the denominator coefficient value');
n1=0:1:N-1;
x1=(n1==0);
h1=filter(b,a,x1);
disp(h1);
subplot(2,1,1);
stem(n1,x1);
title('impulse response');
xlabel('samples');
ylabel('amplitude');
subplot(2,1,2);
stem(n1,h1);
xlabel('samples');
ylabel('amplitude');
%unit step
clc;
clear all;
close all;
N=input('enter the length of the sequence');
a=input('enter the numerator coefficient value');
b=input('enter the denominator coefficient value');
n1=0:1:N-1;
x1=(n1>=0);
h1=filter(b,a,x1);
disp(h1);
subplot(2,1,1);
stem(n1,x1);
title('unit step response');
xlabel('samples');
ylabel('amplitude');
subplot(2,1,2);
stem(n1,h1);
xlabel('samples');
ylabel('amplitude');
% cosine signal
clc;
clear all;
close all;
N=input('enter the length of the sequence');
a=input('enter the numerator coefficient value');
b=input('enter the denominator coefficient value');
n1=0:1:N-1;
x1=cos(0.05*pi*n1);
h1=filter(b,a,x1);
disp(h1);
subplot(2,1,1);
stem(n1,x1);
title('cos signal');
xlabel('samples');
ylabel('amplitude');
subplot(2,1,2);
stem(n1,h1);
xlabel('samples');
ylabel('amplitude');
clear all;
close all;
N=input('enter the length of the sequence');
a=input('enter the numerator coefficient value');
b=input('enter the denominator coefficient value');
n1=0:1:N-1;
x1=(n1>=0);
h1=filter(b,a,x1);
disp(h1);
subplot(2,1,1);
stem(n1,x1);
title('unit step response');
xlabel('samples');
ylabel('amplitude');
subplot(2,1,2);
stem(n1,h1);
xlabel('samples');
ylabel('amplitude');
% cosine signal
clc;
clear all;
close all;
N=input('enter the length of the sequence');
a=input('enter the numerator coefficient value');
b=input('enter the denominator coefficient value');
n1=0:1:N-1;
x1=cos(0.05*pi*n1);
h1=filter(b,a,x1);
disp(h1);
subplot(2,1,1);
stem(n1,x1);
title('cos signal');
xlabel('samples');
ylabel('amplitude');
subplot(2,1,2);
stem(n1,h1);
xlabel('samples');
ylabel('amplitude');














