Effacer les filtres
Effacer les filtres

How to remove outliers from a set of 2D points?

11 vues (au cours des 30 derniers jours)
Hadi Ghahremannezhad
Hadi Ghahremannezhad le 1 Oct 2020
My question has two parts:
  1. I have two 1D arrays containing X and Y values. How can I create another 1D array where each element is a 2D point?
  2. How to remove outliers from the resulting array?
For example, something like this:
x = [1 3 2 4 2 3 400];
y = [2 3 1 4 2 1 500];
xy = [[1 2] [3 3] [2 1] [4 4] [2 2] [3 1] [400 500]];
result = rmoutliers(xy, 'mean');
The result should look like:
result = [[1 2] [3 3] [2 1] [4 4] [2 2] [3 1]]
  2 commentaires
John D'Errico
John D'Errico le 1 Oct 2020
Arrays in MATLAB are not composed of multiple elements in every element. Those extra square brackets were meaningless.
For example, this just creates a row vector of length 14.
xy = [[1 2] [3 3] [2 1] [4 4] [2 2] [3 1] [400 500]];
Better is to use a 2 dimensional array. Thus
xy = [1 2;3 3;2 1;4 4;2 2;3 1;400 500];
xy =
1 2
3 3
2 1
4 4
2 2
3 1
400 500
As you can see, I dropped the spurious brackets.
Anyway, a number is just a symbol. It has no intrinsic meaning unless you put some meaning to the symbol. In this case, I might consider each row as representing the (x,y) coordinates of a point in 2-dimensions.
Hadi Ghahremannezhad
Hadi Ghahremannezhad le 1 Oct 2020
Thanks, I wanted to use 2D array, but the rmoutliers does not work the way I want with 2D matrix.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by