Cut off frequency doesn't works.

8 views (last 30 days)
Reji G
Reji G on 5 May 2022
Commented: Reji G on 10 May 2022
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');

Answers (1)

Chunru
Chunru on 5 May 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 Comments
Reji G
Reji G on 10 May 2022
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).

Sign in to comment.

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!