How to find a unexpected high value and make them to be mean of 2 neighboring values?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Statistics and Machine Learning Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!