Clear Filters
Clear Filters

Comparision of data names

1 view (last 30 days)
Veilchen1900
Veilchen1900 on 7 May 2017
Commented: Veilchen1900 on 9 May 2017
Hi, I want to read images into the workspace and compare the image names with the image names stored in a cell array. My aim is to get the row from the cell aray where the image names are identical. The cell array contains data from an excelsheet (first column = name of image, second-fifth columns = values). With the code below I only get the name of the first image in dir. How do I get the position of the second, third,..image (stored in dir) from the cell array? Thanks in advance.
My code:
files = dir('*.tiff');
a=files.name
t={a}
[rn,cn]=find(strcmp(CellArray,t))

Accepted Answer

Jan
Jan on 8 May 2017
Edited: Jan on 8 May 2017
t = {files.name};
[Lia, Locb] = ismember(CellArray, t);
Or perhaps:
[Lia, Locb] = ismember(CellArray(:, 1), t);
Maybe:
[Common, Index] = intersect(CellArray(:, 1), t);

More Answers (0)

Categories

Find more on File Operations 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!