I am trying to load all 16 images. When I run my code now, Only the last image is saved and can be displayed. Even when I include "loadedimage= imread(Image)" and "imshow(loadedimage)" in the for loop this still occurs. Thanks for any help!
for k=1:16 fileName = strcat('image',num2str(k),'.bmp'); Image= char(fileName); end loadedimage= imread(Image); imshow(loadedimage)

2 件のコメント

Magdy Saleh
Magdy Saleh 2018 年 8 月 7 日
You are overwriting the image variable at every iteration of the loop
Ashley Lewis
Ashley Lewis 2018 年 8 月 7 日
Ok thanks! Any way I can avoid this?

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

 採用された回答

Stephen23
Stephen23 2018 年 8 月 7 日
編集済み: Stephen23 2018 年 8 月 7 日

0 投票

N = 16;
C = cell(1,N);
for k = 1:N
F = sprintf('image%d.bmp',k);
C{k} = imread(F);
end
All of the images will be in cell array C.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2018 年 8 月 7 日

編集済み:

2018 年 8 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by