how to change from one directory to another

3 Ansichten (letzte 30 Tage)
Ogheneochuko
Ogheneochuko am 1 Dez. 2015
Kommentiert: Stephen23 am 3 Dez. 2015
Hello, I have two folders in a parent folder. One folder contains jpg images while the other contains mat files. I then create 3 separate folders within which I want to process the data in the two original folders and store them in the 3 created folders using for loops for each of the 3 folders. After processing and storing data in the first folder, how can I come out of that folder and access the second folder to process and store data before going out of it and accessing the third folder and doing the same. Thanks for any assistance.
  1 Kommentar
Stephen23
Stephen23 am 3 Dez. 2015
Rather than changing directories, you should pass a path argument to your functions. This is much more reliable and robust, as the link in Image Analyst's Answer's explains.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

valdal
valdal am 1 Dez. 2015
Hello Ogheneochuko,
You can use the function 'cd' and the double dot to go to the parent directory :
cd ..
or
cd('..')
('..' represent the parent directory while '.' represent the current directory)
If you want to come out of the current folder and access an other folder :
cd ../folder2
or
cd('../folder2')

Weitere Antworten (1)

Image Analyst
Image Analyst am 3 Dez. 2015
If you want an easier time than the above method you accepted, use genpath(). See may attached demo which goes into every subfolder getting filenames.

Kategorien

Mehr zu Search Path finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by