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!

回答(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'))

类别

在 帮助中心 和 File Exchange 中查找有关 Characters and Strings 的更多信息

标签

提问:

2015-12-27

评论:

2015-12-27

Community Treasure Hunt

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

Start Hunting!

Translated by