Returning row and column number

I have a cell array that contains strings like '1206_gm1.tiff', '1306_gm1.tiff', ... and I want to extract the row numbers that contain these strings (by calling from a list of strings). Is it possible to use the 'find' command to extract row/column numbers containing certain strings? If not, how can I approach this problem?
Thank you!

Answers (1)

Use strcmp (or strcmpi for case insensitive comparison) to get a logical array of strings that match. IF you really need the row and column number you can then use find. Fairly often, you can just use the logical array without needing find:
c = {'1206_gm1.tiff'; '1306_gm1.tiff'; 'some other string'};
row = find(strcmp(c, '1306_gm1.tiff'))

Categories

Tags

Asked:

on 27 Dec 2015

Commented:

on 27 Dec 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!