Folder into which AttachedFiles are written
folder = getAttachedFilesFolder
folder = getAttachedFilesFolder(FileName)
| Character string indicating location where files from
job's |
FileName | Character string specifying all or part of the attached file or folder name |
folder = getAttachedFilesFolder
returns
a string, which is the path to the local folder into which AttachedFiles
are
written on the worker. This function returns an empty array if it
is not called on a MATLAB® worker.
folder = getAttachedFilesFolder(FileName)
returns
the path name to the specified attached folder on the worker, or the
folder containing the specified attached file. FileName
can
match either the full name of the attached file or folder, or on the
ending part of the name. Multiple match results return a cell array.
If you have attached a folder, this does not match on file names within that folder.
Suppose you attach the folder 'C:\monday\tuesday\wednesday\thursday'
,
which on the workers is stored in /tmp/MDCS/tp12345
.
The following table displays the results of various match attempts.
Specified Matching String Argument | Result |
---|---|
getAttachedFilesFolder('C:\monday') | Empty result, because 'C:\monday' is only
the start of the path, and does not include 'thursday' |
getAttachedFilesFolder('wednesday') | Empty result, because 'wednesday' is in
the middle of the path and does not include 'thursday' |
getAttachedFilesFolder('thurs') | Empty result, because 'thurs' is not the
ending of the folder name. |
getAttachedFilesFolder('thursday') | '/tmp/MDCS/tp12345' |
getAttachedFilesFolder('wednesday\thursday') | '/tmp/MDCS/tp12345' |
Attach a folder to a parallel pool, then find its location on the worker to execute one of its files.
myPool = parpool; addAttachedFiles(myPool,'mydir'); spmd folder = getAttachedFilesFolder('mydir'); oldFolder = cd(folder); % Change to that folder [OK,output] = system('myExecutable'); cd(oldFolder); % Change to original folder end
Attach an executable file to a parallel pool, then change to its folder for accessing and processing some data.
myPool = parpool; addAttachedFiles(myPool,'myExecutable'); spmd system('myExecutable'); % Now on MATLAB path folder = getAttachedFilesFolder('myExecutable'); oldFolder = cd(folder); fid = open('myData.txt'); % Access data file % Process fid close(fid) cd(oldFolder); % Change back to the original folder end