clear all;
close all;
clc;
%% creating a low pass prototype filter
filtobj=lpfilt3; %MATLAB generated function from fdatool
h=impz(filtobj.Numerator,1)'; % creating low pass filter
%% choosing the number of bands
cc=input('Enter Number of Bands = ');
M=cc; % number of banks
%% zero padding to make the number of elements of impulse response integer multiple of M
if rem(length(h),M)~=0
h=[h zeros(1,M-rem(length(h),M))];
end
%% downsampling and putting them into different bands
for i=1:M
h1=reshape(h,[M numel(h)/M]);
end
%% upsample and delay
for i=1:M
h2(i,:)=upsample(h1(i,:),M);
h2(i,:)=delayseq(h2(i,:)',i-1)';
end
%% taking the fourier transform of the impulse response of each bands
for i=1:M
h2(i,:)=fft(h2(i,:));
end
%% multiplication of inverse DFT matrix and fourier transform of the impulse response in frequency domain
H=M*inv(dftmtx(M))*h2;
%% watch filter response
for i=1:M
subplot(M,4,i), stem(linspace(-pi,pi,numel(H(i,:)))/pi, fftshift(abs(H(i,:))));
% str=['Magnitude Response of Filter Bank ' num2str(i)];
% ylabel(['\mid E_{' num2str(i) '}(\omega) \mid']);
% xlabel('\omega');
% title(str);
end
%% buiding a signal
N=numel(H(1,:));
n=1:N;
x=zeros(1,numel(n));
for i=0.1:0.1:2
x=x+2*i*sin(i*pi*n);
end
%% watcing filter output
X=fft(x,length(H));
for i=1:M
Y(i,:)=X.*H(i,:);
end
for i=1:M
subplot(M,4,M+i), stem(linspace(-pi,pi,numel(Y(i,:)))/pi, fftshift(abs(Y(i,:))));
% str=['Magnitude Response of the Output from Filter Bank ' num2str(i)];
% ylabel(['\mid Y_{' num2str(i) '}(\omega) \mid']);
% xlabel('\omega');
% title(str);
end
%% watching recontruction
Y=sum(Y)/M;
err=abs(Y)-abs(X);
subplot(M,4,[2*M+1:3*M]), stem(linspace(-pi,pi,numel(X))/pi, fftshift(abs(X)))
% ylabel('\mid X (\omega) \mid');
% xlabel('\omega');
% str=[num2str(length(H)) '-point Fourier Transform of the original signal.'];
% title(str);
subplot(M,4,[3*M+1:4*M]), stem(linspace(-pi,pi,numel(Y))/pi, fftshift(abs(Y)))
% ylabel('\mid Y (\omega) \mid');
% xlabel('\omega');
% str=['Magnitude response of the signal recontructed from filter outputs.'];
% title(str);
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.