how to change from one directory to another

3 次查看(过去 30 天)
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 个评论
Stephen23
Stephen23 2015-12-3
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.

请先登录,再进行评论。

采纳的回答

valdal
valdal 2015-12-1
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')

更多回答(1 个)

Image Analyst
Image Analyst 2015-12-3
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.

类别

Help CenterFile Exchange 中查找有关 Search Path 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by