필터 지우기
필터 지우기

Cut off frequency doesn't works.

조회 수: 1 (최근 30일)
Reji G
Reji G 2022년 5월 5일
댓글: Reji G 2022년 5월 10일
The change in Cut off frequency doen't reflects in output. How to correct ? Also I wnta to display Y axis in dB.
clc;
close all;
clear all;
Fs=200e3;
Ts=1/Fs;
t=0:Ts:(5e-3-Ts);
y=5*sin(2*pi*1000*t)+5*sin(2*pi*20000*t)+10*sin(2*pi*30000*t);
nfft=length(y);
nfft2=2.^nextpow2(nfft);
fy=fft(y,nfft2);
fy=fy(1:nfft2/2);
xfft=Fs.*(0:nfft2/2-1)/nfft2;
cut_off=1.5e3/Fs/2;
order=32;
h=fir1(order,cut_off);
con=conv(y,h);
fh=fft(h,nfft2);
fh=fh(1:nfft2/2);
mul=fh.*fy;
figure(1)
subplot(4,1,1);
plot(t,y);title('Raw signal');xlabel('Time in Sec'),ylabel('Amplitude');
subplot(4,1,2);plot(xfft,abs(fy/max(fy)));title('Freq domain Spark');xlabel('Frequency in Hz'),ylabel('Magnitude');
subplot(4,1,3);plot(abs(mul/max(mul)));title('Filtered output-Frequency domain');xlabel('Frequency in Hz'),ylabel('Magnitude');
subplot(4,1,4);plot(con);title('Filtered output-Time domain');xlabel('Frequency in Hz'),ylabel('Amplitude');

답변 (1개)

Chunru
Chunru 2022년 5월 5일
Fs=200e3;
Ts=1/Fs;
t=0:Ts:(5e-3-Ts);
y=5*sin(2*pi*1000*t)+5*sin(2*pi*20000*t)+10*sin(2*pi*30000*t);
nfft=length(y);
nfft2=2.^nextpow2(nfft);
fy=fft(y,nfft2);
fy=fy(1:nfft2/2);
xfft=Fs.*(0:nfft2/2-1)/nfft2;
% normalize frequency by Fs/2
% cut_off=1.5e3/Fs/2;
cut_off=1.5e3/(Fs/2);
order=32;
h=fir1(order,cut_off);
con=conv(y,h);
fh=fft(h,nfft2);
fh=fh(1:nfft2/2);
mul=fh.*fy;
figure(1)
subplot(4,1,1);
plot(t,y);title('Raw signal');xlabel('Time in Sec'),ylabel('Amplitude');
subplot(4,1,2);plot(xfft,abs(fy/max(fy)));title('Freq domain Spark');xlabel('Frequency in Hz'),ylabel('Magnitude');
subplot(4,1,3);
plot(xfft, abs(mul/max(mul)));
title('Filtered output-Frequency domain');xlabel('Frequency in Hz'),ylabel('Magnitude');
subplot(4,1,4);
plot((0:length(con)-1)/Fs, con);
title('Filtered output-Time domain');xlabel('Time in Sec'),ylabel('Amplitude');
  댓글 수: 7
Chunru
Chunru 2022년 5월 6일
편집: Chunru 2022년 5월 6일
>>> I changed the fc value to 49Hz. Still the graph is same as you plotted and uploaded here.
If the cut-off is 49 Hz and signal is 50Hz, you may not able to filter out the signal. The filter response is never an ideal cut off it has transition band. Zoom in the filter response and check out how much attenuation you have. if you change the cut-off to a smaller value eg. 20Hz), you may filter out the signal at 50Hz.
>>> As far as my knowlege concerned, If my cutoff freq is 49Hz then signals upto 49Hz should be available at the output rest of the signals should be rejected. Am I correct ? (If I'm wrong, plz correct me. I'm a beginner).
For ideal filter with a sharp edge, this is true. For any real implemental filter, this is wrong. Again, check out the filter response.
==> Also I need y axis in dB, x axis in frequency. So that I can see the frequency corresponds to -3dB. Any help would be highly appreciated.
The magnitude response of the filter is in dB. If you want to show the spectraum of signal, you can alwase use 20*log10(abs(fft(x))).
Reji G
Reji G 2022년 5월 10일
I have a mixed signal, which is having different signals ranging from 50Hz to 10^6Hz. From this mixed signal I want to extract frequency components less than 450Hz. How can I do it ? Also I want to plot frequency Vs Magnitude in dB(Thereby I can observe the frequency corresponds to -3dB).

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

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by