mkdir with variable name
조회 수: 93 (최근 30일)
이전 댓글 표시
Hi, i want to make directory. This directory is in a directory which name depends on a variable. How can i do this? This is part of my code.
for l=1:10
...
mkdir('c:\...\demence\' int2str(l) '\','coef')
...
end
It is not working. Thanks for help.
댓글 수: 0
채택된 답변
Sean de Wolski
2013년 5월 7일
See the first example here:
You're close:
mkdir(['c:' 'c:\...\demence\' int2str(l) '\']);
or
mkdir(sprintf('c:\%i',l))
댓글 수: 4
Sean de Wolski
2013년 5월 8일
You need to put the string inside of square brackets to concatenate it first, just like I did.
추가 답변 (1개)
Anmol Pardeshi
2018년 2월 8일
편집: Anmol Pardeshi
2018년 2월 8일
for a=1:1000
subfolder_name=char(%pick information from a variable whos folder name is expected and store here);
cd F:\OutputFolder %route to the parent folder of output
mkdir(['F:\OutputFolder\',subfolder_name])
...
end
댓글 수: 1
Walter Roberson
2018년 2월 8일
projectdir = 'F:\OutputFolder';
for a = 1 : 1000
subfolder_name=char(%pick information from a variable whos folder name is expected and store here);
mkdir( fullfile(projectdir, subfolder_name) );
end
참고 항목
카테고리
Help Center 및 File Exchange에서 Search Path에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!