[英]Find index of element in cell array of matrices
我想在矩阵的单元格数组中找到特定矩阵的索引(在行和列中),例如,如果我有
A = [2 3;4 1]
和
B = {[2 2;1 1] [2 3;4 1] [1 1;1 1]}
那么我想返回2 (因为B{2}==A )。
2
B{2}==A
我想解决这个问题,而不for ,虽然我没有到,单元阵列基本上是小,但我想这样做不for呢。
for
我搜索了这一点,并发现这和这对SO,但他们的解决方案只针对那些没有在这里我字符串的工作。
那么如何在没有for循环的情况下解决这个问题呢?
A是普通矩阵而不是单元素单元格数组, B是矩阵的单元格数组。
A
B
一些可能性:
使用带有isequal cellfun来测试B每个元素是否相等:
isequal
cellfun
find(cellfun(@(x) isequal(x,A), B))
如果所有矩阵的大小相同 :串联成3D数组(或者更好的是,从头开始使用3D数组),然后使用bsxfun进行比较:
bsxfun
find(all(all(bsxfun(@eq, A, cat(3, B{:})),1),2))
[英]How to find index of the last non-empty element in a cell array
[英]How do I find the maximum of each dimension in a cell array of matrices?
[英]Find index of an element in an array in PHP
[英]How to find the index of an element in an array?
[英]Find row Index of strings in cell Array (Matlab)
[英]Add cells in cell array of matrices
[英]Elementwise sum of matrices in cell array
[英]find index of array element in another array javascript
[英]Better way to find array element index?
[英]Rotate array and find index of maximum element
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.