Eliminating the noise from the raw data using median filter

18 vues (au cours des 30 derniers jours)
N/A
N/A le 27 Nov 2022
Commenté : Mathieu NOE le 31 Jan 2023
Hi everyone,
I have a raw csv file data and when I am to plot it, it seems pretty noisy. What I wanted to do ıs either the entire signal(data); or just along the decay curve to be smoothened; in other words; deleting the noise as much as possible. I'd be appreciated if anyone could help me out.
Here's the code that I am dealing with. Apart from reading the csv file, I also come across a similar code on the community so I was trying to modify it.
% Remove quiet parts of a signal.
clc;
close all;
clear;
workspace;
format long g;
format compact;
fontSize = 25;
data= readmatrix('T0027CH1.CSV');
x=data(:,1);
y=data(:,2);
y=(y+35.6);
x=(x+0.8*10^(-3));
N = 125013; % length(col1) if doing the whole signal
col1 = data(1:N, 1);
subplot(2, 2, 1);
plot(col1,y,'b-')
grid on
title('Original Signal', 'FontSize', fontSize);
subplot(2, 2, 2);
col1a = medfilt1(abs(col1),50000);
plot(col1a,y,'b-')
title('After median filter', 'FontSize', fontSize);
threshold = 50;
yline(threshold, 'Color', 'r', 'LineWidth', 2)
grid on;
badIndexes = col1a < threshold;
subplot(2, 2, 3);
plot(badIndexes,y, 'b-', 'LineWidth', 2);
title('Bad parts', 'FontSize', fontSize);
grid on;
% Remove bad indexes.
col1(badIndexes) = [];
subplot(2, 2, 4);
plot(col1,'b-')
grid on;
title('Bad parts removed', 'FontSize', fontSize);
  2 commentaires
Mathieu NOE
Mathieu NOE le 28 Nov 2022
hi
to better help you we need the data file as well
N/A
N/A le 28 Nov 2022
Hi,
Sorry I thought I already attached my raw file. Please see enclosed the csv file.
Thank you.

Connectez-vous pour commenter.

Réponses (1)

Mathieu NOE
Mathieu NOE le 28 Nov 2022
hello again
is it now smooth enough ?
% Remove quiet parts of a signal.
clc;
close all;
clear;
workspace;
format long g;
format compact;
fontSize = 25;
data= readmatrix('T0027CH1.CSV');
x=data(:,1);
y=data(:,2);
y=(y+35.6);
x=(x+0.8*10^(-3));
% removing x NaNs
idx = ~isnan(x);
x = x(idx);
y = y(idx);
ys = smoothdata(y,'gaussian',2500);
plot(x,y,'b',x,ys,'r')
legend('raw','smoothed');
  4 commentaires
Mathieu NOE
Mathieu NOE le 6 Déc 2022
hello
problem solved ?
Mathieu NOE
Mathieu NOE le 31 Jan 2023
hello again
If my submission fullfills your request, do you mind accepting it ?
tx

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by