2011-05-27 107 views
0

我有一些像这样的数字vee(:,:)。它有30行2列。如何在matlab中取最小和最大的矩阵?

当我尝试获取第二列的最小值和最大值时,我使用;

ymax = max(vee(:,2)); 
ymin = min(vee(:,2)); 

它的工作原理

时,我想的第一列的最小值和最大值,我用

xmax = max(vee(1,:)); 
xmin = min(vee(1,:)); 

我不知道关于矩阵方面我可能是错的。为什么xmin和xmax不工作?它只给了我第一行的值。这里有什么问题?

回答

8
在MATLAB

vee(:,i) % gives you the ith column 
vee(i,:) % gives you the ith row 

你在做

vee(:,2) % Right way to access second column 
vee(1,:) % Wrong way to access first column, right way to access first row 

你需要做的

vee(:,1) % Right way to access first column 
2

您应该使用

xmax = max(vee(:,1)); 
xmin = min(vee(:,1)); 

获取第一列。