I want to separate the signal from the noise with the help of a low pass filter.

29 views (last 30 days)
Hello to everyone. I had many signals in the time domain. I first converted these signals to the frequency domain with fft. I am sharing the image of the signal in the frequency domain with you. What I need to do now is to separate the noise from the signal by passing this noisy signal through a low pass filter. but I don't know how to do it as I've never done it before. I would be very happy if you could help with this. They said I can use the firpm command for the filter.
%the code I used to convert to frequency domain
Tt = Time{i,m};
x = signal{i,m};
L = length(Tt);
Ts = mean(diff(Tt));
Fs = 1/Ts;
Fn = Fs/2;
X = fftshift(fft(x)/L);
Fv2 = linspace(-Fn, Fn, L);

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 8 May 2021
I could not figure out which of those signals you want to filter, so I arbitrarily chose ‘t1’ and ‘y1’.
They are not consistently sampled, so I used the resample function to correct that. This will eliminate the high-frequency noise, however I was not able to eliminate the baseline offset using a bandpass filter, since I do not know what constitutes the signal and what constitutes the baseline drift. I leave that to you to experiment with, using:
[yfilt,df] = bandpass(xr, [0.005 0.04], Fs, 'ImpulseResponse','iir');
Experiment with the lower passband frequency to get the result you want.
Try this —
LD = load('Data4.mat');
t = LD.t1;
y = LD.y1;
Tt = t;
x = y;
[xr,Ttr] = resample(x,Tt,4.5);
L = numel(Ttr);
Ts = mean(diff(Ttr));
Tsd = std(diff(Ttr));
Fs = 1/Ts;
Fn = Fs/2;
X = fftshift(fft(xr-mean(xr))/L);
Fv2 = linspace(-Fn, Fn, L);
plot(Fv2, abs(X));
xlim([-0.25 0.25])
[yfilt,df] = lowpass(xr, 0.04, Fs, 'ImpulseResponse','iir');
plot(Ttr, xr, '-b')
title('Original Signal')
plot(Ttr, yfilt, '-r')
title('Filtered Signal')
I cannot run this in the online application since I cannot load .mat files in it.
studentmatlaber on 30 May 2021
@Star Strider Hello again, sorry for asking questions all the time. There was no phase difference when I used the filtfilt command. however, this command does not work with any value other than [0.04 0.5]. When you use these values, too much noise remains in the signal. I want to narrow this range. Do you have an idea?
[n, fo, ao, w] = firpmord ([0.04 0.5], [1 0], [0.001 0.001], Fs{i,m});
Star Strider
Star Strider on 30 May 2021
That vector defines the frequencies, and they are not allowed to be less than or equal to 0 or greater than ‘Fs/2’. Check Fs and make appropriate changes depending on that value.
That is the only possibility I can think of.

Sign in to comment.

More Answers (2)

Image Analyst
Image Analyst on 11 May 2021
What is i and m?
What I'd do it do just zero out the middle of the FFT signal to "zero out" high frequencies. Or zero out the beginning and end of the fft if you shifted it with fftshift() so that the zero frequency point is in the middle. Then inverse transform with ifft(). It's kind of old school and primitive and you have to know what range you want to zero out over (you can experiment). It's probably not as sohpisticated as what Star Strider recommended (certain special MATLAB functions), but this "manual" way might be fine for you.

fyp matlab
fyp matlab on 14 May 2021
you can design low pass filter or any kind of filter using:
command .

Community Treasure Hunt

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

Start Hunting!