mkdir with variable name

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.

 Respuesta aceptada

Sean de Wolski
Sean de Wolski el 7 de Mayo de 2013

1 voto

See the first example here:
You're close:
mkdir(['c:' 'c:\...\demence\' int2str(l) '\']);
or
mkdir(sprintf('c:\%i',l))

4 comentarios

Jakub
Jakub el 7 de Mayo de 2013
I asked worng question. I want to make directory 'coef' in a directory that depends on a variable 'l'...
Sean de Wolski
Sean de Wolski el 7 de Mayo de 2013
How is that any different?
mkdir a\b\c
You can make sub directories with mkdir
Jakub
Jakub el 8 de Mayo de 2013
It shouldnt be but its not working...
mkdir('c:\test\' int2str(l) '\','koef')
mkdir('c:\test\' int2str(l) '\','koef')
|
Error: Unexpected MATLAB expression._**
Sean de Wolski
Sean de Wolski el 8 de Mayo de 2013
You need to put the string inside of square brackets to concatenate it first, just like I did.

Iniciar sesión para comentar.

Más respuestas (1)

Anmol Pardeshi
Anmol Pardeshi el 8 de Feb. de 2018
Editada: Anmol Pardeshi el 8 de Feb. de 2018

1 voto

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 comentario

Walter Roberson
Walter Roberson el 8 de Feb. de 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

Iniciar sesión para comentar.

Categorías

Más información sobre File Operations en Centro de ayuda y File Exchange.

Preguntada:

el 7 de Mayo de 2013

Comentada:

el 8 de Feb. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by