To change Current Folder to the folder of .m File
조회 수: 270(최근 30일)
Image Analyst 2013년 4월 17일
편집: Image Analyst 2013년 4월 17일
Here's some code I got from Brett Shoelson of the Mathworks:
% Change the current folder to the folder of this m-file.
Edit: Note that the isdeployed is important if you will be compiling and deploying your application. This let's it operate both for you, as the developer, and for your deployed application where it will skip the cd because doing cd like that in a deployed app can wreak havoc. If you won't be doing compiling, then you can do just the cd without the if.
Florian 2018년 7월 13일
mfile_name = mfilename('fullpath');
[pathstr,name,ext] = fileparts(mfile_name);