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
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
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')
0 个评论
更多回答(1 个)
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.
And read the FAQ discussion/warning about using cd: http://matlab.wikia.com/wiki/FAQ#Where_did_my_file_go.3F_The_risks_of_using_the_cd_function.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Search Path 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!