Beruflich Dokumente
Kultur Dokumente
clc;
clear all;
close all;
%PASS BAND
figure
%sinewave generation
f=500;
fs=8000;
nts=0:1/fs:1-1/fs;
x=sin(2*pi*f*nts);
f1=0:fs/length(x):fs-fs/length(x);
x_xfft=abs(fft(x));
%impulse response
N=16;
fc=1000;
nfc=fc/(fs/2);
hn=fir1(N,nfc);
FFT_hn=fft(hn,length(nts));
x_hn=abs(fft(hn));
f2=0:fs/length(hn):fs-fs/length(hn);
%Covolution or Filter Output
filter_output=filter(hn,1,x);
FFT_filter_output=abs(fft(filter_output));
%FFT_filter_output=x_xfft.*FFT_hn;
%Time Domain
subplot(3,2,1);
plot(nts,x);
xlabel('t---->');
ylabel('x(t)');
grid on;
subplot(3,2,3);
plot(hn);
xlabel('t--->');
ylabel('h(t)');
grid on;
subplot(3,2,5);
plot(filter_output);
xlabel('t----->');
ylabel('y(t)')
grid on;
%Frequency Domain
subplot(3,2,2);
stem(f1,x_xfft);
xlabel('n--->');
ylabel('x(n)');
grid on;
subplot(3,2,4);
stem(f2,x_hn);
xlabel('n----->');
ylabel('h(n)');
grid on;
subplot(3,2,6);
stem(f1,FFT_filter_output);
xlabel('n---->');
ylabel('y(n)');
grid on;
%CUTOFF FREQ
figure
%sinewave generation
f=1000;
fs=8000;
nts=0:1/fs:1-1/fs;
x=sin(2*pi*f*nts);
f1=0:fs/length(x):fs-fs/length(x);
x_xfft=abs(fft(x));
%impulse response
N=16;
fc=1000;
nfc=fc/(fs/2);
hn=fir1(N,nfc);
FFT_hn=fft(hn,length(nts));
x_hn=abs(fft(hn));
f2=0:fs/length(hn):fs-fs/length(hn);
FFT_filter_output=abs(fft(filter_output));
%FFT_filter_output=x_xfft.*FFT_hn;
%Time Domain
subplot(3,2,1);
plot(nts,x);
xlabel('t---->');
ylabel('x(t)');
grid on;
subplot(3,2,3);
plot(hn);
xlabel('t--->');
ylabel('h(t)');
grid on;
subplot(3,2,5);
plot(filter_output);
xlabel('t----->');
ylabel('y(t)')
grid on;
%Frequency Domain
subplot(3,2,2);
stem(f1,x_xfft);
xlabel('n--->');
ylabel('x(n)');
grid on;
subplot(3,2,4);
stem(f2,x_hn);
xlabel('n----->');
ylabel('h(n)');
grid on;
subplot(3,2,6);
stem(f1,FFT_filter_output);
xlabel('n---->');
ylabel('y(n)');
grid on;
%TRANSITION BAND
figure
%sinewave generation
f=1050;
fs=8000;
nts=0:1/fs:1-1/fs;
x=sin(2*pi*f*nts);
f1=0:fs/length(x):fs-fs/length(x);
x_xfft=abs(fft(x));
%impulse response
N=16;
fc=1000;
nfc=fc/(fs/2);
hn=fir1(N,nfc);
FFT_hn=fft(hn,length(nts));
x_hn=abs(fft(hn));
f2=0:fs/length(hn):fs-fs/length(hn);
filter_output=filter(hn,1,x);
FFT_filter_output=abs(fft(filter_output));
%FFT_filter_output=x_xfft.*FFT_hn;
%Time Domain
subplot(3,2,1);
plot(nts,x);
xlabel('t---->');
ylabel('x(t)');
grid on;
subplot(3,2,3);
plot(hn);
xlabel('t--->');
ylabel('h(t)');
grid on;
subplot(3,2,5);
plot(filter_output);
xlabel('t----->');
ylabel('y(t)')
grid on;
%Frequency Domain
subplot(3,2,2);
stem(f1,x_xfft);
xlabel('n--->');
ylabel('x(n)');
grid on;
subplot(3,2,4);
stem(f2,x_hn);
xlabel('n----->');
ylabel('h(n)');
grid on;
subplot(3,2,6);
stem(f1,FFT_filter_output);
xlabel('n---->');
ylabel('y(n)');
grid on;
%STOP BAND
figure
%sinewave generation
f=1600;
fs=8000;
nts=0:1/fs:1-1/fs;
x=sin(2*pi*f*nts);
f1=0:fs/length(x):fs-fs/length(x);
x_xfft=abs(fft(x));
%impulse response
N=16;
fc=1000;
nfc=fc/(fs/2);
hn=fir1(N,nfc);
FFT_hn=fft(hn,length(nts));
x_hn=abs(fft(hn));
f2=0:fs/length(hn):fs-fs/length(hn);
filter_output=filter(hn,1,x);
FFT_filter_output=abs(fft(filter_output));
%FFT_filter_output=x_xfft.*FFT_hn;
%Time Domain
subplot(3,2,1);
plot(nts,x);
xlabel('t---->');
ylabel('x(t)');
grid on;
subplot(3,2,3);
plot(hn);
xlabel('t--->');
ylabel('h(t)');
grid on;
subplot(3,2,5);
plot(filter_output);
xlabel('t----->');
ylabel('y(t)')
grid on;
%Frequency Domain
subplot(3,2,2);
stem(f1,x_xfft);
xlabel('n--->');
ylabel('x(n)');
grid on;
subplot(3,2,4);
stem(f2,x_hn);
xlabel('n----->');
ylabel('h(n)');
grid on;
subplot(3,2,6);
stem(f1,FFT_filter_output);
xlabel('n---->');
ylabel('y(n)');
grid on;
OUTPUT
Figure1
Figure2
Figure3
Figure4