声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 8691|回复: 4

[编程技巧] 如何用max找二维数组中最大值的坐标

[复制链接]
发表于 2008-10-7 03:36 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
clc
clear

a=[1 2 3;4 7 3;3 10 4];
[B,I]=max(a(:));
已经找到最大值的是第I个数字,如何得到二维的坐标即:(3,2)

先谢谢
回复
分享到:

使用道具 举报

发表于 2008-10-7 09:07 | 显示全部楼层
help ind2sub

评分

1

查看全部评分

 楼主| 发表于 2008-10-7 20:31 | 显示全部楼层
谢谢lsd
matlab无所不能:lol
发表于 2008-10-8 22:48 | 显示全部楼层

回复 沙发 rocwoods 的帖子

学习学习!
由于电脑上不能装Matlab,已经有半年没有接触了!
能否介绍一下ind2sub命令?
谢谢啦
发表于 2008-10-8 23:07 | 显示全部楼层

回复 地板 ch_j1985 的帖子

怕翻译不准确了影响你的理解。
最笨的方法-------直接贴上来了哈。。:lol
IND2SUB Multiple subscripts from linear index.
    IND2SUB is used to determine the equivalent subscript values
    corresponding to a given single index into an array.

    [I,J] = IND2SUB(SIZ,IND) returns the arrays I and J containing the
    equivalent row and column subscripts corresponding to the index
    matrix IND for a matrix of size SIZ.  
    For matrices, [I,J] = IND2SUB(SIZE(A),FIND(A>5)) returns the same
    values as [I,J] = FIND(A>5).

    [I1,I2,I3,...,In] = IND2SUB(SIZ,IND) returns N subscript arrays
    I1,I2,..,In containing the equivalent N-D array subscripts
    equivalent to IND for an array of size SIZ.

    Class support for input IND:
       float: double, single

评分

1

查看全部评分

您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-23 03:26 , Processed in 0.057510 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表