Remove specific outliers from double
이전 댓글 표시
I want to remove outliers from a double using the rmoutliers function, combied with "datavariables" to select the columns from which the outliers should be removed. See the code below.
mData3=rmoutliers(mData3,'percentiles',[5 95],'DataVariables',[3 4]);
The addition of the "datavariables" argument messes with the function and leads to no output. It seems that it only works with a table datatype, however I am unable to convert the double to a table. (I also need the data to be in the double-form)
Is there another solution?
Kind regards
댓글 수: 3
Dyuman Joshi
2023년 8월 16일
"however I am unable to convert the double to a table."
Why is that?
Also, after converting the data into a table, and removing the outliers for 3rd and 4th column (if you there are any) you will not be able to convert the data back into a double array, because the size of the output will not match for concatenation.
Konstantin Koerber
2023년 8월 16일
"I tried array2table but it didn't work."
Can you attach your code and data?
Suppose your data is this -
A = magic(12);
A = A(:,1:4);
A(3,3) = -200;
A(4,4) = -300;
disp(A)
%3rd column
isoutlier(A(:,3),"percentiles",[5 95])'
%4th column
isoutlier(A(:,4),"percentiles",[5 95])'
What should be the final output here?
답변 (1개)
Use normal indexing to replace the outliers in certain columns using filloutliers.
A = magic(5);
A(3, :) = A(3, :) + 100 % Create outliers
A(:, [2 4]) = filloutliers(A(:, [2 4]), NaN)
Note that you can't remove outliers in this scenario, as that would lead to a matrix with different length columns and that is not allowed in MATLAB numeric arrays.
A(:, [1 5]) = rmoutliers(A(:, [1 5]))
카테고리
도움말 센터 및 File Exchange에서 Tables에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!