I'm using pwd
function to generate current path in app designer of MATLAB R2016a but this function finds MATLAB current folder (main window of MATLAB) not app designer current folder. What should I do?
Asked
Active
Viewed 2,235 times
0
-
1I don't understand what you're asking. MATLAB doesn't have multiple current directories. – sco1 Aug 17 '16 at 08:24
-
@excaza. When we use `pwd` in app designer, this function finds MATLAB current folder in main window not the path that the designed app is running there (we don't have this problem in `GUIDE`). When we run an app in `GUIDE`, this app changes the current folder of MATLAB to `GUIDE` app, so `pwd` function finds the app path (same as current folder of MATLAB in this situation). – Eghbal Aug 17 '16 at 08:26
-
1Possible duplicate of [Find location of current m-file in MATLAB](http://stackoverflow.com/questions/2720140/find-location-of-current-m-file-in-matlab) – sco1 Aug 17 '16 at 12:25
-
@excaza. Thank you. Please add your answer. + we need to remove file name in the end of path. – Eghbal Aug 18 '16 at 10:37
1 Answers
2
I was also looking for the answer of your question. In the comments of your question the hardest part of the problem was given by "excaza". But I eventually used:
[directory,~,~] = fileparts(mfilename('fullpath'));
Good luck

Buskebam
- 21
- 3
-
This works only once. Close the app and open again OR call the method twice, it will give MATLAB working directory. – Meow Cat 2012 Nov 01 '21 at 04:51