How to check for outliers in only 1 column in a matrix
4 views (last 30 days)
Show older comments
I have a huge dataset with 30 columns of data, columns 6 and 7 are latitude and longitude respectivly. I am trying to find and remove ouliers from just these two columns. There are definitly outliers in other columns of data but thats fine, I want to find oultiers from columns 6 and 7 and remove the row they belong to. The code ive been using until now is:
M = readmatrix(F);
[M1, ~, ~] = rmoutliers(M,1);
When the matrix is created (M) and outliers are removed it removes the first few thousand columns. Likely because one of the other columns have outliers, those outliers dont matter to me and I want them included. When I plot lat and long with no outliers removed I can see there are probably 30 or so outliers related to position, they either have the sign flipped or are 0. I tried to specify the column using:
[M1, ~, ~] = rmoutliers(M(:,6),1);
but got an error:
Index in position 2 exceeds array bounds. Index must not exceed 1.
Error in USV/bpf_btn (line 238)
Roll1 = M1(:,2);
^^^^^^^
meaning the second column of data is no longer being read. How do I specify the column I want to check for outliers and remove that row? Thank you again for your time.
0 Comments
Answers (1)
Torsten
on 4 Dec 2024
Moved: Torsten
on 4 Dec 2024
A= [1 5 20;-2 16 3;4 3 -1067];
[~,idx] = rmoutliers(A(:,2))
[~,jdx] = rmoutliers(A(:,3))
A = A(~idx&~jdx,:)
2 Comments
Walter Roberson
on 4 Dec 2024
A= [1 5 20;-2 16 3;4 3 -1067];
[~,kdx] = rmoutliers(A(:,2:3))
A(~kdx,:)
See Also
Categories
Find more on Trigonometry 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!