How to search for a string in cell array in MATLAB?
I guess the following code could do the trick: strs = {‘HA’ ‘KU’ ‘LA’ ‘MA’ ‘TATA’} ind=find(ismember(strs,’KU’)) This returns ans = 2
I guess the following code could do the trick: strs = {‘HA’ ‘KU’ ‘LA’ ‘MA’ ‘TATA’} ind=find(ismember(strs,’KU’)) This returns ans = 2
Think of cell array as a regular homogenic array, whose elements are all cells. Parentheses (()) simply access the cell wrapper object, while accessing elements using curly bracers ({}) gives the actual object contained within the cell. For example, A={ [5,6], 0 , 0 ,0 }; Will look like this: The syntax of making an … Read more
Here’s one solution that uses cellfun with an anonymous function to first pad each cell with NaN values, then vertcat to put the cell contents into a matrix: tcell = {[1 2 3], [1 2 3 4 5], [1 2 3 4 5 6], [1], []}; % Sample cell array maxSize = max(cellfun(@numel, tcell)); % … Read more