How to find a unexpected high value and make them to be mean of 2 neighboring values?
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Statistics and Machine Learning Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!