How do I exclude certain columns from rmmissing rmoutliers?
14 views (last 30 days)
Show older comments
HI, I have a university assignment and I want to remove missing data and outliers, but there are some columns that I dont want to be affected by this. Is there any way to do that?
0 Comments
Accepted Answer
Star Strider
on 18 May 2023
Edited: Star Strider
on 18 May 2023
I would treat those as two separate operations.
First, remove the missing data on the entire matrix, not only selectyed columns, The reason for this is to keep the matrix column lengths the same, and so all the rows with non-missing data remain the same.
Removing the outliers is similar.
I would instead use fillmissing for the missing data, and then selectively use filloutliers for the columns you want to process with it. This keeps the matrix structure intact.
To select the columns, just choose the ones you want to process —
A = randn(10, 7);
A(randi(numel(A),1,10)) = 10*randn(1,10)
Afilloutliers = filloutliers(A(:,[2 5 7]), 'linear','grubbs')
Aedited = A;
Aedited(:,[2 5 7]) = Afilloutliers;
figure
plot(1:10, A)
grid
ylim([-50 50])
figure
plot(1:10, Aedited)
grid
ylim([-50 50])
EDIT — (18 May 2023 at 19:00)
Added example.
.
4 Comments
More Answers (0)
See Also
Categories
Find more on Timetables 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!