0% found this document useful (0 votes)
24 views1 page

All All

This document contains code to generate a test signal, apply a high pass filter to remove frequencies below 500 Hz, and perform an FFT to analyze the filtered signal in the frequency domain. It generates a multi-sine test signal, designs an 8th order FIR high pass filter with a cutoff of 500 Hz, applies the filter to the test signal using a sliding window approach, and plots the original, filtered and frequency spectra of the filtered signal.

Uploaded by

Yogi Mahardika
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views1 page

All All

This document contains code to generate a test signal, apply a high pass filter to remove frequencies below 500 Hz, and perform an FFT to analyze the filtered signal in the frequency domain. It generates a multi-sine test signal, designs an 8th order FIR high pass filter with a cutoff of 500 Hz, applies the filter to the test signal using a sliding window approach, and plots the original, filtered and frequency spectra of the filtered signal.

Uploaded by

Yogi Mahardika
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

close all;

clear all;
clc;
%---------------- Signal Generator ------------------------------------
Fsampling = 1000; % Sampling frequency
T = 1/Fsampling; % Sampling period
L = 1500; % Length of signal
t = (0:L-1)*T; % Time vector
x = sin(2*pi*20*t)+sin(2*pi*100*t)+sin(2*pi*1000*t);

%-----------------FIR Digital Filter (Fcutoff HPF 500 Hz)-------------

b0= 0.0051 ;b1=-0.0294;b2=0.1107 ;b3=-0.2193;b4=0.2710;b5=-0.2193 ;


b6=0.1107;b7=-0.0294 ;b8= 0.0051;
x7=0;x6=0;x5=0;x4=0;x3=0;x2=0;x1=0;x0=0;

for i=1:L
x8=x7;
x7=x6;
x6=x5;
x5=x4;
x4=x3;
x3=x2;
x2=x1;
x1=x0;
x0=x(i);
y=b0*x0 + b1*x1 + b2*x2 + b3*x3 + b4*x4 + b5*x5 + b6*x6...
+ b7*x7 + b8*x8;
yfilter(i)=y;
end
y = yfilter';

%-----------------Fast Fourier Transform (FFT) ----------------------


n = 2^nextpow2(L);
Yfft = fft(y,n);
P2 = abs(Yfft/L);
P1 = P2(1:n/2+1);
P1(1:end-1) = 2*P1(1:end-1);
figure;
subplot(3,1,1); plot(t,x);
title ('Original Signal');
subplot (3,1,2);plot(t,y);
title ('Filtered Signal');
subplot(3,1,3);plot(0:(Fsampling/n):(Fsampling/2-Fsampling/n),P1(1:n/2));
title ('Frequency of the signal');

You might also like