get
説明
例
ValueStore
オブジェクトからの値の取得
ワーカー上でシミュレーションを実行し、クライアント上でジョブのデータ ストレージを取得します。データ ストレージは、キーと値のエントリをもつ ValueStore
オブジェクトです。対応するキーでの指定どおりに、このオブジェクトから値を取得します。
次のシミュレーションでは、乱数行列の逆行列を求め、結果を ValueStore
オブジェクトに保存します。
type workerInvCode
function workerInvCode(models) % Get the ValueStore of the current job store = getCurrentValueStore; for i = 1:numel(models) % Store simulation results in the ValueStore object pause(1); key = strcat("result_",num2str(i)); store(key) = inv(rand(models(i))); end end
既定のクラスター プロファイルを使用して、ワーカー上でバッチ ジョブを実行します。
models = [4,8,32,20]; c = parcluster; job = batch(c,@workerInvCode,0,{models}); wait(job);
クライアント上の ValueStore
オブジェクトを取得します。
store = job.ValueStore;
キー "result_1"
で指定されたエントリ値をオブジェクトから取得します。
val2 = store("result_1")
val2 = 4×4
-0.1302 0.5240 1.0774 -0.6338
-0.3234 1.6059 -1.3149 0.3445
0.5687 -2.8018 1.0625 1.5465
0.5670 2.3518 -0.9865 -1.3971
キー "result_3"
および "result_4"
で指定された複数の値をオブジェクトから取得します。
valArray = get(store,["result_3","result_4"])
valArray=1×2 cell array
{32×32 double} {20×20 double}
入力引数
store
— MATLAB® クライアントとワーカーで共有されるデータ ストレージ
ValueStore
オブジェクト
MATLAB クライアントとワーカーで共有されるデータ ストレージ。ValueStore
オブジェクトとして指定します。
keySet
— 取得する値のキー
文字ベクトル | string スカラー | string 配列 | 文字ベクトルまたは string の cell 配列
取得する値のキー。文字ベクトル、string スカラー、string 配列、もしくは文字ベクトルまたは string の cell 配列として指定します。
ヒント
key
での指定どおりに 1 つのエントリ値のみを返すには、構文value = store(key)
を使用することもできます。
バージョン履歴
R2022a で導入
参考
ValueStore
| isKey
| keys
| remove
| put
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)