Returning row and column number
Show older comments
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)
Guillaume
on 27 Dec 2015
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'))
1 Comment
Andrew Lee
on 27 Dec 2015
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!