get - Get values from ValueStore object - MATLAB (original) (raw)

Main Content

Get values from ValueStore object

Since R2022a

Syntax

Description

`valueSet` = get([store](#mw%5F9ab163e6-2a76-48e7-b67d-d7964cc8d7f2),[keySet](#mw%5F6387b330-a270-42bb-ad73-2d6ebe1a7429)) returns the values from the ValueStore object store as specified by the keys keySet. valueSet is a cell array containing the returned values, which are in the same order as their corresponding keys inkeySet.

example

Examples

collapse all

Run a simulation on workers and retrieve the data storage of the job on a client. The data storage is a ValueStore object with key-value entries. Get values from this object as specified by its corresponding keys.

The following simulation finds the inverse of random matrices and stores the results in the ValueStore object.

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

Run a batch job on workers using the default cluster profile.

models = [4,8,32,20]; c = parcluster; job = batch(c,@workerInvCode,0,{models}); wait(job);

Retrieve the ValueStore object on the client.

Get the entry value as specified by the key "result_1" from the object.

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

Get multiple values as specified by the keys "result_3" and "result_4" from the object.

valArray = get(store,["result_3","result_4"])

valArray=1×2 cell array {32×32 double} {20×20 double}

Input Arguments

collapse all

Data storage shared by MATLAB clients and workers, specified as a ValueStore object.

Keys to retrieve values at, specified as a character vector, string scalar, string array, or cell array of character vectors or strings.

Tips

Version History

Introduced in R2022a