Remove specific outliers from double
1 view (last 30 days)
Show older comments
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 Comments
Dyuman Joshi
on 16 Aug 2023
Edited: Dyuman Joshi
on 16 Aug 2023
"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?
Answers (1)
Steven Lord
on 16 Aug 2023
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]))
0 Comments
See Also
Categories
Find more on Tables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!