Azzera filtri
Azzera filtri

How to find a unexpected high value and make them to be mean of 2 neighboring values?

1 visualizzazione (ultimi 30 giorni)
Hello
I have a matrix with 4 columns. As the data are experimental, sometimes there are sudden jumps. Then, I want to code it in a way that column 4th to be checked by matlab and those jumps (in this example: 400) to be discovered and changes to a mean of neighboring values (or if it is first or last number of the column, changes to near value). At the end, this matrix to be saved as csv file. (Since data are experimental, there is no rule to find this kind of error values in 4th column. I can say, it is at least 3 times bigger than neighing values)
I tried following code that considers whole “column mean” and also other one called as “rmoutliers” but they make mistake in removing data and make a mess. I will be grateful if someone can propose a way for this.
A = [2 3 4 2; 5 3 7 3; 8 9 0 6; 5 6 1 400]
as = length (A (:, 4))
M = mean (A (:, 4))
for i = 1: as
Max = max (A (:, 4))
if Max> 3 * M
A (A == Max) = 0
else end
end
fname = sprintf ( 'new.csv' );
csvwrite (fname, A); % Write to CSV file
  3 Commenti
Masoud Taleb
Masoud Taleb il 12 Mag 2020
How to discover those big elements in column when we do not know how many of them are present? This is the main question.

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Tables in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by