フィルターのクリア

problem with %d in MATLAB

8 ビュー (過去 30 日間)
naila
naila 2013 年 8 月 1 日
Hi all;
I have image file having 01.dcm, 02.dcm, 03.dcm ... 22.dcm;
I want to read all these images with loop. How can I do it Please. I am just confuse with %d command as it can't recognize 01.dcm etc. it is just recognize 1.dcm, 2.dc, ...

採用された回答

David Sanchez
David Sanchez 2013 年 8 月 1 日
for k = 1:22
pic2read = strcat(num2str(k),'.dcm');
if k<10
pic2read = strcat('0',pic2read);
end
imread(pic2read);
end
  5 件のコメント
Jan
Jan 2013 年 8 月 1 日
Adding the '0' manually is a really inefficient solution. See Andrei's much nicer and faster sprintf method.
Walter Roberson
Walter Roberson 2013 年 8 月 1 日

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

その他の回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2013 年 8 月 1 日
for k = 1:22, imread(sprintf('%02d.dcm',k)); end
  1 件のコメント
Jan
Jan 2013 年 8 月 1 日
編集済み: Jan 2013 年 8 月 1 日
+1. This is compact, direct, fast, not prone to typos.

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

カテゴリ

Help Center および File ExchangeHistorical Contests についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by