Cut off frequency doesn't works.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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');
0 comentarios
Respuestas (1)
Chunru
el 5 de Mayo de 2022
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 comentarios
Chunru
el 6 de Mayo de 2022
Editada: Chunru
el 6 de Mayo de 2022
>>> 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))).
Ver también
Categorías
Más información sobre Filter Analysis en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!