listbox, filtering with 2 conditions
Show older comments
I want to filter files that I read into a list box. I am currently filtering depending if they contain red.tiff.
ImageFiles = dir([folder '\*red.tif*']);
How can I combine another filter together with this one. Depending on the users choice (either C1, C2, C3), I want only those files that contain red.tiff AND e.g. contain the C1 in their filenames.
can I use: ImageFiles = dir([folder '\*C1*red.tif*']);
1 Comment
Jason
on 23 Sep 2014
Answers (1)
Geoff Hayes
on 23 Sep 2014
Edited: Geoff Hayes
on 23 Sep 2014
filenameFilter = sprintf('*%s*red.tif*',CM);
ImageFiles = dir(fullfile(folder,filenameFilter));
If CM is 'C6', then
filenameFilter =
*C6*red.tif*
The fullfile function builds the string that includes the folder path and filename filter, inserting platform-dependent file separators where necessary (so that you don't have to worry about them).
Categories
Find more on Dates and Time 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!