我想在MATLAB中找到矩阵中数字的位置 [英] i want to find the location of a number in a matrix in matlab

查看:1328
本文介绍了我想在MATLAB中找到矩阵中数字的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个矩阵可以说

x =
 2     2     3
 4     3     2
 6     4     8

现在我想获取数字4的位置.
我想要这样的ans:

now I want to get the location of a number 4.
I want ans like this :

ans=(2,1) (3,2)

因为这些是矩阵中4的位置.

as these are the locations for 4 in matrix.

推荐答案

使用 find :

[i,j] = find(x == 4)

这篇关于我想在MATLAB中找到矩阵中数字的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆