Run a simulation on a parallel pool of process workers and retrieve the file storage on a client. The file storage is a FileStore object with key-file entries. Copy files from this object as specified by their corresponding keys using the copyFileFromStore function.
The following simulation finds the average and standard deviation of random matrices and stores the results in the FileStore object.
type workerStatsCode
function workerStatsCode(models)
% Get the FileStore of the current job
store = getCurrentFileStore;
for i = 1:numel(models)
% Compute the average and standard deviation of random matrices
A = rand(models(i));
M = mean(A);
S = std(A);
% Save simulation results in temporary files
sourceTempFile = strcat(tempname("C:\myTempFolder"),".mat");
save(sourceTempFile,"M","S");
% Copy files to FileStore object as key-file pairs
key = strcat("result_",num2str(i));
copyFileToStore(store,sourceTempFile,key);
end
end
Start a parallel pool of process workers.
pool = parpool('Processes');
Starting parallel pool (parpool) using the 'Processes' profile ...
Connected to the parallel pool (number of workers: 6).
File storage shared by MATLAB clients and workers, specified as a FileStore
object.
Keys to copy, specified as a character vector, string scalar, string array, or cell
array of character vectors or strings. keySet and
fileSet must have the same number of elements.
Example: ["myDataKey" "myLogKey"]
Local files, specified as a character vector, string scalar, string array, or cell
array of character vectors or strings. keySet and
fileSet must have the same number of elements.
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.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: United States.
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.