matlab找最大值,如何在MATLAB中的矩阵列中找到最大值的索引?

I'm trying to find the maximum value of a certain column in a matrix. I want to find both the maximum value and the index of the row in which it is. How can I do this?

解决方案

max command can find both the maximal value and its index.

Here's an example:

>> A = randn(10,3)

A =

0.8884 -0.10224 -0.86365

-1.1471 -0.24145 0.077359

-1.0689 0.31921 -1.2141

-0.8095 0.31286 -1.1135

-2.9443 -0.86488 -0.0068493

1.4384 -0.030051 1.5326

0.32519 -0.16488 -0.76967

-0.75493 0.62771 0.37138

1.3703 1.0933 -0.22558

-1.7115 1.1093 1.1174

>> [maxVal maxInd] = max(A)

maxVal =

1.4384 1.1093 1.5326

maxInd =

6 10 6

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值