Remove specific outliers from double
Ältere Kommentare anzeigen
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 Kommentare
Dyuman Joshi
am 16 Aug. 2023
"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
am 16 Aug. 2023
Dyuman Joshi
am 16 Aug. 2023
Bearbeitet: Dyuman Joshi
am 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?
Antworten (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]))
Kategorien
Mehr zu Tables finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!