Reputation: 81
I'm looking for a command to get a general file path in MATLAB. I'm looking to be able to run my code across multiple computers.
Example
fullfile('','C:','users','XXXXXX','Desktop','Matlab Data')
Is it possible to get this fullfile
location off of where the MATLAB code is stored so that it can be used later in the code for file execution, regardless of what computer it's executing it?
Upvotes: 0
Views: 43
Reputation: 949
From within a function called foo
:
function x = foo( )
x=fullfile(fileparts(mfilename('fullpath')),'lorem','ipsum');
% fun stuff
end
This should work regardless of your current working directory.
Upvotes: 3