Ignore anomalies in collection of datasets

3 views (last 30 days)
MADRobot
MADRobot on 29 Jun 2020
Commented: MADRobot on 30 Jun 2020
I want to ignore anomalies in datasets contained within a for loop. However, I'm not sure how to do this where:
  • i = number of rows, and my code will step through it to produce an animation made up of >1000 frames. For example:
RPtoT = [RASIS(i,:); RT2(i,:); RT3(i,:)];
LPtoT = [LASIS(i,:); LT0(i,:); LT1(i,:)];
I want to exlude anomolies that cause my markers to jump around. For example, half way through the moving figure, a few markers will suddenly jump from an x position of 2000 to 0 - I want to be able to ignore these, so almost filter the data, but I don't know how to do this and apply it to a lot more data similar to the code displayed above.
for i = 1:1033
if i<10
i = [NaN]; % I want the values contained within i to be neglected if they randomly bounce towards zero
else
i = i;
end
I don't want to have to go through 50+ datasets with a matrices of 1000+ by 3 and set anomalies to NaN, so is there an easier way to do this?

Answers (1)

Steven Lord
Steven Lord on 29 Jun 2020
Preprocess your data to identify, fill, and/or remove outliers. Use the functions in the "Missing Data and Outliers" section on that page or use the Live Editor Task "Clean Outlier Data" also described on that page.
  1 Comment
MADRobot
MADRobot on 30 Jun 2020
I've tried to integrate this into my current code, but it doesn't seem to be working.
An example of how I've done this:
[cleanedData,outlierIndices] = rmoutliers([L5MT LLMal LMMal LAnkle R5MT RLMal RMMal RAnkle], 'ThresholdFactor',6);
I've also tried applying it as:
[cleanedData,outlierIndices] = rmoutliers(R5MT, 'ThresholdFactor',6);
[cleanedData,outlierIndices] = rmoutliers(RLMal, 'ThresholdFactor',6);
[cleanedData,outlierIndices] = rmoutliers(RMMal, 'ThresholdFactor',6);
[cleanedData,outlierIndices] = rmoutliers(RAnkle, 'ThresholdFactor',6);
It doesn't seem to be making any difference for some reason, I'm pretty sure I'm doing something wrong but I don't know what I'm doing wrong.

Sign in to comment.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!