How to use find function to find input of 'cell' type?
6 次查看(过去 30 天)
显示 更早的评论
Hello, I have 'raw' as an array of all cells read from excel (number or non-number). I would like to find the row numbers where the cell is 'ABC', and return the first row.
When I use 'find' function it returns an error:
>>find(raw, 'ABC','first')
Undefined function 'find' for input arguments of type 'cell'.
Is there a way to find the row for a cell content in Matlab? If so, how can I find the row of both that one vector having some cell, and another vector having another cell?
4 个评论
采纳的回答
Image Analyst
2015-4-15
ca = {'abc', 'def';
'abcx', 'row 2';
'yy', 'row 2 abc';
'zzzz', 'abc';
'abc', 'line 3'}
[ia, ib] = ismember(ca, 'abc')
firstRow = find(ia(:, 1), 1, 'first')
In the command window:
ca =
'abc' 'def'
'abcx' 'row 2'
'yy' 'row 2 abc'
'zzzz' 'abc'
'abc' 'line 3'
ia =
1 0
0 0
0 0
0 1
1 0
ib =
1 0
0 0
0 0
0 1
1 0
firstRow =
1
2 个评论
Image Analyst
2015-4-16
编辑:Image Analyst
2015-4-16
Please create a cell array like I did so I can work on it. And tell me which row and column you want to find/detect and return to your program.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!