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

17 views (last 30 days)
studentmatlaber on 6 May 2021
Commented: Star Strider on 30 May 2021
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);
studentmatlaber on 7 May 2021
@Star Strider Actually I have 24 .mat files, but I can throw 1 of them from here.

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 —
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);
figure;
plot(Fv2, abs(X));
grid;
xlabel('Frequency');
ylabel('Amplitude');
xlim([-0.25 0.25])
[yfilt,df] = lowpass(xr, 0.04, Fs, 'ImpulseResponse','iir');
figure
subplot(2,1,1)
plot(Ttr, xr, '-b')
grid
title('Original Signal')
subplot(2,1,2)
plot(Ttr, yfilt, '-r')
grid
title('Filtered Signal')
I cannot run this in the online application since I cannot load .mat files in it.
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.

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 on 14 May 2021
you can design low pass filter or any kind of filter using:
filterDesigner
command .