MATLAB 도움말 센터
Identify folder on a worker where attached files are copied to
folder = getAttachedFilesFolder
folder = getAttachedFilesFolder(filename)
folder = getAttachedFilesFolder returns the path to the folder on the current worker where attached files are copied to. Attached files are specified by the AttachedFiles of the job that the worker is currently running.
folder
AttachedFiles
If getAttachedFilesFolder is evaluated on a worker, folder is the path to the local folder. Otherwise, folder is an empty character vector.
getAttachedFilesFolder
folder = getAttachedFilesFolder(filename) uses filename to search for files or folders in the attached files folder.
filename
Attached files are specified by the AttachedFiles of the job that the worker is currently running. A match is found if a file or folder specified in the AttachedFiles property ends with filename. If a folder is specified in the AttachedFiles property, no matches can be found for any files in that folder.
If only one file or folder matches, folder is the path to that file or folder. If multiple files or folders match, folder is a cell array containing every matching path. If filename does not match the name of an attached file or folder, folder is an empty cell array.
example
collapse all
Use the addAttachedFiles function to attach a folder to a parallel pool, then use the getAttachedFilesFolder function to find the folder on workers.
addAttachedFiles
Create a parallel pool with 4 workers.
p = parpool(4);
Starting parallel pool (parpool) using the 'Processes' profile ... Connected to parallel pool with 4 workers.
The current directory contains two folders myFolder1 and myFolder2, containing files myFile1.csv and myFile2.csv respectively.
myFolder1
myFolder2
myFile1.csv
myFile2.csv
dir myFolder*/*
Files Found in: myFolder1 . .. myFile1.csv Files Found in: myFolder2 . .. myFile2.csv
Use addAttachedFiles to attach the two folders to the pool.
addAttachedFiles(p,{'myFolder1','myFolder2'});
When you use addAttachedFiles, the folders are copied to workers. Each copied folder will have a unique name on the workers.
Then, use getAttachedFilesFolder on the workers to get the path to the copy of 'myFolder1'. Use readtable to read the file myFile1.csv in the folder.
'myFolder1'
readtable
parfor i = 1 folder = getAttachedFilesFolder('myFolder1'); filepath = fullfile(folder, 'myFile1.csv'); t = readtable(filepath); end
Name of file or folder to search for in the attached files available on the current worker, specified as a string or character vector. Attached files are specified by the AttachedFiles of the job that the worker is currently running.
Example: "myFile1.csv"
"myFile1.csv"
Data Types: string | char
string
char
Folder containing attached files available on the current worker, specified as a character vector or cell array.
If filename is specified, folder is the path or paths matching filename. If only one file or folder matches, filename is the path to that file or folder. If multiple files or folders match, filename is a cell array containing every matching path. If filename does match the name of an attached file or folder, folder is an empty cell array.
If filename is not specified, folder is the path containing attached files available to the worker.
If getAttachedFilesFolder is not evaluated on a worker, folder is an empty character vector.
Data Types: char | cell
cell
Introduced in R2012a
getCurrentCluster
getCurrentJob
getCurrentTask
getCurrentWorker
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
유럽
아시아 태평양
지역별 지사에 문의