copyFileToStore
说明
示例
将文件复制到 FileStore
对象
在进程工作进程的并行池上运行仿真并检索客户端上的文件存储。文件存储是一个带有关键文件条目的 FileStore
对象。使用 copyFileToStore
函数按照其相应键的指定将文件复制到此对象。
以下仿真查找随机矩阵的平均值和标准差,并使用 copyFileToStore
将结果存储在 FileStore
对象中。
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
启动一个并行进程工作进程。
pool = parpool("Processes");
Starting parallel pool (parpool) using the 'Processes' profile ... Connected to the parallel pool (number of workers: 6).
获取该池的 FileStore
。
store = pool.FileStore;
在池上运行仿真。
models = [4,8,32,20]; future = parfeval(@workerStatsCode,0,models); wait(future);
输入参数
store
— MATLAB® 客户端和工作进程共享的文件存储
FileStore
对象
由 MATLAB 客户端和工作进程共享的文件存储,指定为 FileStore
对象。
fileSet
— 本地文件
字符向量 | 字符串标量 | 字符串数组 | 字符向量或字符串的元胞数组
本地文件,指定为字符向量、字符串标量、字符串数组、或者字符向量或字符串的单元格数组。fileSet
和 keySet
必须具有相同数量的元素。
示例: ["/data/run.mat" "/tmp/run_log.txt"]
keySet
— 要添加的键
字符向量 | 字符串标量 | 字符串数组 | 字符向量或字符串的元胞数组
要添加的键,指定为字符向量、字符串标量、字符串数组、或者字符向量或字符串的单元格数组。fileSet
和 keySet
必须具有相同数量的元素。
示例: ["myDataKey" "myLogKey"]
版本历史记录
在 R2022a 中推出
另请参阅
FileStore
| isKey
| keys
| remove
| copyFileFromStore
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
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: .
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.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)