copyFileFromStore
説明
例
FileStore
オブジェクトからのファイルのコピー
プロセス ワーカーの並列プール上でシミュレーションを実行し、クライアント上のファイル ストレージを取得します。ファイル ストレージは、キーとファイルのエントリをもつ FileStore
オブジェクトです。関数 copyFileFromStore
を使用して、対応するキーでの指定どおりに、このオブジェクトからファイルをコピーします。
次のシミュレーションでは、乱数行列の平均と標準偏差を求め、結果を 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);
FileStore
オブジェクトのキーを表示します。
keys(store)
ans = 4×1 string
"result_1"
"result_2"
"result_3"
"result_4"
対応するキー "result_1"
および "result_2"
による指定どおりに、ファイル ストレージからローカル ファイル "run_1.mat"
および "run_2.mat"
にファイルをコピーします。
copyFileFromStore(store,["result_1" "result_2"],["run_1.mat" "run_2.mat"])
ローカル ファイルに保存されている変数の情報をすべて表示します。
whos -file 'run_1.mat'
Name Size Bytes Class Attributes M 1x4 32 double S 1x4 32 double
whos -file 'run_2.mat'
Name Size Bytes Class Attributes M 1x8 64 double S 1x8 64 double
入力引数
store
— MATLAB® クライアントとワーカーで共有されるファイル ストレージ
FileStore
オブジェクト
MATLAB クライアントとワーカーで共有されるファイル ストレージ。FileStore
オブジェクトとして指定します。
keySet
— コピーするキー
文字ベクトル | string スカラー | string 配列 | 文字ベクトルまたは string の cell 配列
コピーするキー。文字ベクトル、string スカラー、string 配列、もしくは文字ベクトルまたは string の cell 配列として指定します。keySet
と fileSet
の要素数は同じでなければなりません。
例: ["myDataKey" "myLogKey"]
fileSet
— ローカル ファイル
文字ベクトル | string スカラー | string 配列 | 文字ベクトルまたは string の cell 配列
ローカル ファイル。文字ベクトル、string スカラー、string 配列、もしくは文字ベクトルまたは string の cell 配列として指定します。keySet
と fileSet
の要素数は同じでなければなりません。
例: ["/data/run.mat" "/tmp/run_log.txt"]
バージョン履歴
R2022a で導入
参考
FileStore
| isKey
| keys
| remove
| copyFileToStore
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)