查找索引矩阵的Matlab [英] Find index matrix Matlab

查看:216
本文介绍了查找索引矩阵的Matlab的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

矩阵维和 find 函数有问题。



对于每一行,我试图找到与大于20的值相关的索引,并将结果存储在另一个矩阵中。

例如:

  A = [
10 21 30
1 40 50
1 0 0
50 10 3];


索引=
2 3
2 3
0
1

有什么建议? 使用找到 accumarray

 >> ; [r c] = find(A> 20); 
>> index = accumarray(r,c,[],@(x){x})

index =
[2,3]
[2,3]
[]
[1]

请注意, code>是一个cellarray。


I have a problem with matrix dimension and the find function.

For each row, I'm trying to find the index related to the value greater than 20 and store the result in another matrix.

For example:

A = [
    10  21  30
     1  40  50
     1   0   0 
    50  10   3];


index = 
    2 3 
    2 3
    0
    1

Any suggestions?

解决方案

Use find and accumarray

>> [r c] = find( A > 20 );
>> index = accumarray( r, c, [], @(x) {x} )

index = 
 [ 2, 3 ]
 [ 2, 3 ]
       []
 [    1 ]

Note that index is a cellarray.

这篇关于查找索引矩阵的Matlab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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