Main Content

get

Get values from ValueStore object

Since R2022a

Description

valueSet = get(store,keySet) 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 in keySet.

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.

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

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.

store = job.ValueStore;

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

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

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

  • To return only one entry value as specified by key, you can also use the syntax value = store(key).

Version History

Introduced in R2022a

See Also

| | | |