Azzera filtri
Azzera filtri

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

11 visualizzazioni (ultimi 30 giorni)
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 Commenti
John D'Errico
John D'Errico il 1 Ott 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 il 1 Ott 2020
Thanks, I wanted to use 2D array, but the rmoutliers does not work the way I want with 2D matrix.

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by