Fourier Graphs of my lowpass and high pass filtered signals are looking weird

조회 수: 9 (최근 30일)
Hello everyone,
I am currently doing a project in MATLAB and I am using a lowpass filter in a signal with a cutoff frequency of 30Hz and then I find the fourier transform of it and I graph it. I want to know if the actual graph is right or am I doing something wrong? I am going to attach the part of the code for the filters and plots.
This is the plot that I get for the low pass filter:
It shouldn't go to 0 after 30 Hz? or around 30 Hz?
And for the high pass filter:
I get it to be 0 around until like 190 Hz, but why is it not 270Hz or closer? I did use smaller frequencies for the HPF and they were more accurate until when they stayed 0.
%LPF 30Hz
y_LPF_30 = lowpass(y,30,Fs);
yf_LPF_30 = fft(y_LPF_30);
% 30Hz
%set up
%% Compute the two-sided spectrum P2. Then compute the single-sided spectrum P1 based on P2 and the even-valued signal length L.
P2_LPF30 = abs(yf_LPF_30/L);
P1_LPF30 = P2_LPF30(1:L/2+1);
P1_LPF30(2:end-1) = 2*P1_LPF30(2:end-1);
figure (5)
%plot
subplot(3,2,1);
plot(f,P1_LPF30)
title('Single-Sided Amplitude Spectrum of LPF 30Hz')
xlabel('f (Hz)')
ylabel('|P1(f)|')
%HPF 270Hz
y_HPF_270 = highpass(y,270,Fs);
yf_HPF_270 = fft(y_HPF_270);
%270Hz
%set up
P2_HPF270 = abs(yf_HPF_270/L);
P1_HPF270 = P2_HPF270(1:L/2+1);
P1_HPF270(2:end-1) = 2*P1_HPF270(2:end-1);
%plot
subplot(3,2,6);
plot(f,P1_HPF270)
title('Single-Sided Amplitude Spectrum of HPF 270Hz')
xlabel('f (Hz)')
ylabel('|P1(f)|')
  댓글 수: 2
Nicolas Picon
Nicolas Picon 2019년 12월 11일
편집: Nicolas Picon 2019년 12월 11일
That typo explains the high pass filter question, oops.
But I don't know what happens with the LPF.
The code that I used for f is:
[y,Fs] = audioread('myvoice.m4a');
L = length(y);
f = Fs*(0:(L/2))/L;
Nicolas Picon
Nicolas Picon 2019년 12월 11일
Also, the original sound signal graph is this:
Unfiltered Sound Signal.JPG
And the Fourier Transform graph of the original signal is this:
Fourier Transform of Original Signal.JPG
I don't know if this helps

댓글을 달려면 로그인하십시오.

채택된 답변

Ridwan Alam
Ridwan Alam 2019년 12월 11일
편집: Ridwan Alam 2019년 12월 11일
Last update:
Running your Lowpass code:
%LPF 30Hz
y_LPF_30 = lowpass(y,30,Fs);
yf_LPF_30 = fft(y_LPF_30);
% 30Hz
%set up
%% Compute the two-sided spectrum P2. Then compute the single-sided spectrum P1 based on P2 and the even-valued signal length L.
P2_LPF30 = abs(yf_LPF_30/L);
P1_LPF30 = P2_LPF30(1:L/2+1);
P1_LPF30(2:end-1) = 2*P1_LPF30(2:end-1);
figure
%plot
plot(f,P1_LPF30)
title('Single-Sided Amplitude Spectrum of LPF 30Hz')
xlabel('f (Hz)')
ylabel('|P1(f)|')
gives this output:
untitled.jpg
Update:
For the low-pass try adding some properties such as:
y_LPF_30 = lowpass(y,30,Fs,'StopbandAttenuation',100);
Also, please show us the plots generated by this:
lowpass(y,30,Fs,'StopbandAttenuation',100);
lowpass(___) with no output arguments plots the input signal and overlays the filtered signal.
Hope it helps.
Earlier:
The filters look ok. some example data would be helpful to debug.
Also, it might just be a typo, but you wrote: P2_HPF270 = abs(yf_HPF_220/L);
  댓글 수: 5
Ridwan Alam
Ridwan Alam 2019년 12월 11일
After running
lowpass(y,30,Fs,'Steepness',0.95,'StopbandAttenuation',100)
the result looks like this:
untitled.jpg

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by