ディレクトリ 変更 ループ

조회 수: 12 (최근 30일)
Ukasu
Ukasu 2020년 1월 17일
답변: Kenta 2020년 1월 17일
日付ごとのフォルダがあり、フォルダごとに同じ作業を繰り返したいのですが、どうすればいいですか。
たとえばA,B,Cという3つのディレクトリがあり,下のようにそれぞれのディレクトリで同じ作業を行いたいです。
sdir = ['A','B','C'];
for n=1:3
cd sdir(n)
% 何かしらの作業。例えば、
I=dir('*.jpg');
size(I);
end

채택된 답변

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 検索パス에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!