How to use the same filename more than once in a loop?

2 ビュー (過去 30 日間)
D Aghor
D Aghor 2018 年 11 月 23 日
コメント済み: D Aghor 2018 年 11 月 24 日
I am using the mini-MIAS database that contains 322 mammogram image files that are named as mdb001.pgm, mdb002.pgm, ....... mdb322.pgm. Some of the images are to be used twice or thrice. I have created a vector of filenames as
imname=(mdb001, mdb002, .... mdb005, mdb005, ......., mdb126, mdb126, mdb126, mdb127,....., mdb322)
How to write a loop that can call these images as the sequence given in the vector.

採用された回答

Geoff Hayes
Geoff Hayes 2018 年 11 月 23 日
D - if your vector of filenames is really a cell array of strings, then you could try something like
filenames = {'mdb001.pgm', 'mdb002.pgm', 'mdb005.pgm'};
for file = filenames
% convert to string/character array if necessary
fileAsString = char(file);
% do something
fprintf('%s\n',fileAsString);
end
  1 件のコメント
D Aghor
D Aghor 2018 年 11 月 24 日
Thanks. It helped me to solve the problem.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDatabase Toolbox についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by