基于 Matlab/Octave 中坐标值的点的分段矩阵

Segment matrix of points based on coordinate values in Matlab/Octave

我有一个二维坐标的 (n, 2) 矩阵。根据 x 或 y 坐标将矩阵分割或拆分为不同部分的最有效方法是什么?我只是在寻找矩形区域,所以可以完成以下操作,例如:

split_on_y_value(PointMatrix, yvalue) -> returns Matrix1 = [all points with y<yvalue] and Matrix2 = [all points with y>=yvalue]

get_points_in_range(PointMatrix, y1, y2) -> returns 1 matrix will all points with y value in between y1 and y2

我知道这与图像分割有关,但这是一个简单得多的问题,我只是不知道要使用正确的 Matlab/Octave 符号或包。

解决方案非常简单。这是 y < yvalue 案例:

A=randi(10,10,2)
yvalue=7;

B=A(A(:,2)<yvalue,:)

输出为:

A =

   7   7
   7   9
   2   1
   7   9
   7   1
   3   7
   9   6
   3   9
   9   4
   6   4

B =

   2   1
   7   1
   9   6
   9   4
   6   4

正如他们所说,问题的其余部分留作 reader 的练习。