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

11 次查看(过去 30 天)
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 个评论
John D'Errico
John D'Errico 2020-10-1
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
Thanks, I wanted to use 2D array, but the rmoutliers does not work the way I want with 2D matrix.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by