【问题标题】:How to take min and max of a matrix in matlab?如何在matlab中取矩阵的最小值和最大值?
【发布时间】:2011-05-27 19:47:06
【问题描述】:

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

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

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

有效

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

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

我不知道矩阵维度我可能是错的。为什么 xmin 和 xmax 不起作用?它只给了我第一行的值。这里有什么问题?

【问题讨论】:

    标签: matlab


    【解决方案1】:

    在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));
      

      获取第一列。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-06-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-02-07
        相关资源
        最近更新 更多