フィルターのクリア

how to concatenate image variable

3 ビュー (過去 30 日間)
Itai Kadosh
Itai Kadosh 2018 年 1 月 10 日
コメント済み: Itai Kadosh 2018 年 1 月 10 日
Hi,
I have a sequence of images such as - img1,img2...img10 and I need to send them to a function as images via loop. If I use the following code rows, I get vector that include a string variables (like 'img1', 'img2'...) and I can't send them to the function as image:
for i=1:10
Img(i)=['img',num2str(i)];
end
How can I define a vector of these images as a variables not as string for sending them through the function?
Thanks, Itai
  1 件のコメント
Stephen23
Stephen23 2018 年 1 月 10 日
Put the images into one array, e.g. a cell array or an ND numeric array. Then your task is trivial to achieve using simple, very efficient indexing.
Whatever you do, do NOT try to magically access variable names in a loop: this will make your code slow, complex, buggy, obfuscated, and hard to debug. Read this to know more:

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

採用された回答

KSSV
KSSV 2018 年 1 月 10 日
編集済み: KSSV 2018 年 1 月 10 日
YOu can get all the images present in the folder using:
img = dir('*.jpg') ; % give your extension
for i = 1:length(img)
img(i).name
end
  1 件のコメント
Itai Kadosh
Itai Kadosh 2018 年 1 月 10 日
thanks!

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by