Finding all occurences of a string within a cell array (itself part of a struc)

Refresh

April 2019

Views

4 time

0

I have the following structure

dataDens = 

     dens: [1x172 double]
    level: {1x172 cell}
     raga: {1x172 cell}

within which dataDens.raga consists of (reducing the number of columns below for simplicity)

Columns 1 through 3
    'Multani'    'Tori'    'Tori' 

I'd like to find the indices at which 'Tori' appears (that is, [2 3] for the example above). However, all of the commands I tried (below) either give an error, or return blank outputs. I think it's probably just a matter of adding/removing a curly bracket somewhere, or using some conversion; but I am at my wit's end, and hope someone can help clarify

indices = find(strcmp([dataDens.raga{:}], {'Tori'}))
indices = ismember('Tori', dataDens.raga)
[if,where] = ismember('Tori', dataDens.raga)

0 answers