Not able to cd into a folder

1 visualización (últimos 30 días)
Yash Khandelwal
Yash Khandelwal el 13 de Jul. de 2022
Respondida: Voss el 13 de Jul. de 2022
I have to make a folder in my project and then cd into it but not able to. The code line looks like this:
Then I want to cd into that folder but not able to. Please help

Respuesta aceptada

Anay Aggarwal
Anay Aggarwal el 13 de Jul. de 2022
Hi Yash
I have an understanding that you want to create a folder and then cd into it while runtime.
Following might help:
mkdir("dB_"+name); % create a folder
cd ([ 'dB_' convertContainedStringsToChars(name) ]);
This would create a folder and cd into it while runtime.

Más respuestas (1)

Voss el 13 de Jul. de 2022
Maybe check that mkdir successfully creates the directory:
status = mkdir("dB_"+name)
status = logical
Here status is true, so we know the directory was created.
Then cd into it:
cd() % show the current working directory
If mkdir returns false, it means mkdir was not able to create the directory, maybe because you don't have write permissions in the parent directory (i.e., the directory you're in when you call mkdir).


Más información sobre Startup and Shutdown en Help Center y File Exchange.


Community Treasure Hunt

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

Start Hunting!

Translated by