Filter löschen
Filter löschen

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

11 Ansichten (letzte 30 Tage)
Hadi Ghahremannezhad
Hadi Ghahremannezhad am 1 Okt. 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 Kommentare
John D'Errico
John D'Errico am 1 Okt. 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 am 1 Okt. 2020
Thanks, I wanted to use 2D array, but the rmoutliers does not work the way I want with 2D matrix.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by