What is the difference between directory, path and current folder in matlab?
How can you locate these paths?
Good question.
A directory (aka folder) is a normal file system directory. The current (working) directory or folder is the one retrieved by the pwd() function. Other functions working on the current directory are cd() and dir().
More important than the current folder is the path (aka search path). It is an ordered list of folders. The current folder is always, implicitly, at the top of the path.
Now if MATLAB needs to load a file from the file system, it is loaded according the path. That is, if the file is not in pwd(), then MATLAB will descend along the path until it finds the file.
For example fileread(), fopen() or the *.m file loading work that way, only to mention a few.
It is good practice not to rely on the current directory or cd()-ing into different folders. The reason is that
Edit
Also handle addpath() with care. You should not use it inside a function if you care to compile it.
Compiled applications cannot modify the path. The only path elements are the unpacked CTF archive and the current directory, but now the latter is at the bottom of the path, not at the top as for MATLAB sessions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With