2012-08-30 83 views
1

我有一组坐标值,我想将这些值相互比较。我想要x-min,x-max,y-min,y-max作为结果。 例如: (10,40) 和 (20,30) 是两组值。 我想比较他们; 它应该是结果:比较图像的两个坐标值

x-min=10 
y-min=30 
x-max=20 
y-max=40 

回答

1

听起来很简单:

max(x(:)); %#Get the maximal value. 
min(x(:)); %#Get the minimal value. 
max(y(:)); %#Get the maximal value. 
min(y(:)); %#Get the minimal value. 

现在你可以对它们进行比较。

2

如果您有单独的阵列xy,请参阅@安德烈的答案。 如果你有一个像

A = [x y] = [ 
    10 40 
    20 30 
    .. 
    90 25]; 

数组然后使用此:

mins = min(A); 
maxs = max(A); 

minX = mins(1); maxX = maxs(1); 
minY = mins(2); maxY = maxs(2);