如何在matlab中获取矩阵的最小值和最大值?

Ada*_*Ada 0 matlab

我有一些像这样的数字vee(:,:).它有30行和2列.

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

ymax = max(vee(:,2));
ymin = min(vee(:,2)); 
Run Code Online (Sandbox Code Playgroud)

有用

当我想要第一列的最小值和最大值时,我会使用

xmax = max(vee(1,:));
xmin = min(vee(1,:));
Run Code Online (Sandbox Code Playgroud)

我不知道矩阵尺寸我可能是错的.为什么xmin和xmax不起作用?它只给出了第一行的值.这有什么不对?

Pav*_*ili 8

在matlab中

vee(:,i) % gives you the ith column
vee(i,:) % gives you the ith row
Run Code Online (Sandbox Code Playgroud)

你在做

vee(:,2) % Right way to access second column
vee(1,:) % Wrong way to access first column, right way to access first row
Run Code Online (Sandbox Code Playgroud)

你需要这样做

vee(:,1) % Right way to access first column
Run Code Online (Sandbox Code Playgroud)