Вы находитесь на странице: 1из 2

code for fft

filter bank

clc;
clear all;
close all;
N=20;
n=0:1:N-1;
x=ones(1,N);
%plot the input
figure
stem(n,x);
lfft=256;
X1=fft(x,lfft);
X2=real(X1);
%plot thr fft of the input
figure
X2=[(X2(lfft/2:lfft)),X2(1:(lfft/2)-1)];
plot(X2);
%plot the absolute value of the fft of the input
Xf=20*(log10(abs(X1)));
Xf=[(Xf(lfft/2:lfft)),Xf(1:(lfft/2)-1)];
figure
plot(Xf)
k=-100:100;
m=k/100*pi;
X=x*exp(-1j*(n')*m);
figure
plot(m,abs(real(X)));hold on
% plot filter bank
for i=1:N-1
X=x*exp(-1j*(n')*(m+2*i*pi/N));
plot(m,abs(real(X)),'--');
end

code for decimated fft fiter bank


clc;
clear all;
close all;
N=50;
n=0:1:N-1;
x=ones(1,N);
y= decimate(x,2);
%plot the decimated input
figure
stem(y)
lfft=512;
lfft1=512/2;
Y=real(fft(y,lfft1));
Y1=fft(y,lfft1)
%plot the fft of the decimated input
figure
Y2=[(Y(lfft1/2:lfft1)),Y(1:(lfft1/2)-1)];
plot(Y2)

%plot the absolute value of the fft of the input


Yf=20*(log10(abs(Y1)));
Yf=[(Yf(lfft1/2:lfft1)),Yf(1:(lfft1/2)-1)];
figure
plot(Yf)
k=-300:300;
m=k/300*pi;
Y=y*exp(-1j*(n')*m);
figure
plot(m,abs(real(Y)));hold on
% plot filter bank
for i=1:N-1
Y=y*exp(-1j*(n')*(m+2*i*pi/N));
plot(m,abs(real(Y)),'--');
end

Вам также может понравиться