Reputation: 5579
Hello I would like to locate the file 'my_file.mat'
that should be somewhere inside the folder 'C:\...\mypath\folder1'
.
the folder folder1
contains several subfolders and the file my_file
could be in any of these subfolders.
I would like to retrieve its full path.
Upvotes: 0
Views: 2855
Reputation: 129
You want to use the which function.
mypath = which('my_file.mat')
As commented below, this assumes that your 'folder1' has been added to your search path. To add (and remove if no longer needed) 'folder1' to your search path:
my_folder_path = 'path/to/folder1'
addpath(genpath(my_folder_path))
mypath = which('my_file.mat')
rmpath(my_folder_path)
Upvotes: 3
Reputation: 4510
I think you are looking for genpath
and which
combo:
addpath(genpath(folderName));
which test.txt -all
>>
Z:\home\**\Documents\MATLAB\R2010b\bin\test.txt
Upvotes: 1