Hi, How could I remove the noise from a mat file? The fs is 30 Hz. I tried to use a low pass filter, but seem not work well. I am not good at programming matlab. Could you fix my code and explain that? clear all; load('examples.mat'); n = 57; y = examples(n).data; figure(1) grid on; plot(y); xlabel('Times'); ylabel('Amplitude'); title('Original Noisy Signal'); fs = 30; fpass = 3; yf = lowpass(y, fpass, fs); figure(2) grid on; plot(yf); xlabel('Times'); ylabel('Amplitude'); title('Filtered Signal');
Prashant Kumar answered .
2025-11-20
D = load('examples.mat');
data = D.ppg.data;
Fs = 30; % Sampling Frequency (Hz)
Fn = Fs/2; % Nyquist Frequency (Hz)
L = numel(data);
t = linspace(0, L, L)/Fs;
figure
plot(t, data)
grid
title('PPG Signal')
xlabel('Time (s)')
ylabel('Amplitude (?)')
datam = mean(data);
FTdata = fft(data - datam)/L;
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
figure
plot(Fv, abs(FTdata(Iv))*2)
grid
title('Fourier Transform - Original Signal')
xlabel('Frequency (Hz)')
ylabel('Amplitude (?)')
xlim([0 7])
datafilt = smoothdata(data, 'rlowess', 15);
datam = mean(datafilt);
FTdatafilt = fft(datafilt - datam)/L;
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
figure
plot(Fv, abs(FTdatafilt(Iv))*2)
grid
title('Fourier Transform - Filtered Signal')
xlabel('Frequency (Hz)')
ylabel('Amplitude (?)')
xlim([0 7])