I have a cell array (n-by-1 dimension) containing both strings and cells, which looks something like this
{
{'r1'} % -> cell content is in format 'char'
{'r2'} % -> cell content is in format 'char'
{1x2 cell} % -> cell content is a cell array: [{'r1'}{'r2'}]
{'r3'} % -> cell content is in format 'char'
{1x2 cell} % -> cell content is a cell array: [{'r1'}{'r3'}]
{1x2 cell} % -> cell content is a cell array: [{'r2'}{'r3'}]
{1x3 cell} % -> cell content is a cell array: [{'r1'}{'r2'}{'r3'}]
...
}
I need to find the row-index where the some string is included, e.g. 'r2'. I usually use strfind for this purpose which works great if the cell array has a consistent format (hence 'char'-format within each cell).
Is there any way to apply this function to the cell array structure which is displayed above?
Thanks!
EDIT: Please find attached three images showing the data structure that I am using, since I am not sure how to exactly show/explain the hierarchies and layers of the cell array in text. Hope that helps. Also find attached the outcome of the code.
Code used:
change = 'r1.m';
srch = cellfun(@(x) strfind(x, change), strats, 'UniformOutput', false);
stringInRow = cellfun(@(x) numel(x) == 1 || (numel(x)>1)*numel(cell2mat(x))>0, srch);
rows = find(stringInRow);




