mkdir with variable name
93 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Jakub
il 7 Mag 2013
Commentato: Walter Roberson
il 8 Feb 2018
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 Commenti
Risposta accettata
Sean de Wolski
il 7 Mag 2013
See the first example here:
You're close:
mkdir(['c:' 'c:\...\demence\' int2str(l) '\']);
or
mkdir(sprintf('c:\%i',l))
4 Commenti
Sean de Wolski
il 8 Mag 2013
You need to put the string inside of square brackets to concatenate it first, just like I did.
Più risposte (1)
Anmol Pardeshi
il 8 Feb 2018
Modificato: Anmol Pardeshi
il 8 Feb 2018
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 Commento
Walter Roberson
il 8 Feb 2018
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
Vedere anche
Categorie
Scopri di più su Search Path in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!