ディレクトリ 変更 ループ

21 vues (au cours des 30 derniers jours)
Ukasu
Ukasu le 17 Jan 2020
Réponse apportée : Kenta le 17 Jan 2020
日付ごとのフォルダがあり、フォルダごとに同じ作業を繰り返したいのですが、どうすればいいですか。
たとえばA,B,Cという3つのディレクトリがあり,下のようにそれぞれのディレクトリで同じ作業を行いたいです。
sdir = ['A','B','C'];
for n=1:3
cd sdir(n)
% 何かしらの作業。例えば、
I=dir('*.jpg');
size(I);
end

Réponse acceptée

Kenta
Kenta le 17 Jan 2020
sdir = ['a','b','c'];
for n=1:3
cd(sdir(n))
I=imread('onion.png');
size(I)
cd ../
end
こんにちは、この例だと、cd ../でディレクトリをもとに戻し、さらにcdで、フォルダに入り、作業...という流れですれば可能です。

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!