简体   繁体   English

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

[英]How to take min and max of a matrix in matlab?

I have something full of numbers like this vee(:,:) .我有很多像这样的数字vee(:,:) It has 30 rows and 2 columns.它有 30 行和 2 列。

When I try to get the min and max of the second column, I use;当我尝试获取第二列的最小值和最大值时,我使用;

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

it works有用

when I want the min and max of the first column, I use当我想要第一列的最小值和最大值时,我使用

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

I don't know about matrix dimensions I might be wrong.我不知道矩阵尺寸我可能是错的。 Why doesn't the xmin and xmax work?为什么 xmin 和 xmax 不起作用? It only gives me the values of the first row.它只给了我第一行的值。 What is wrong here?这里有什么问题?

in matlab在 matlab

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

you were doing你在做

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

You need to do你需要做

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

You should use你应该使用

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

To get the first column.获取第一列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM