mkdir with variable name
129 次查看(过去 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!