Main Content


Retrieve all output arguments from Future


[B1,B2,...,Bn] = fetchOutputs(F)
[B1,B2,...,Bn] = fetchOutputs(F,'UniformOutput',false)


[B1,B2,...,Bn] = fetchOutputs(F) fetches all outputs of the Future object F after first waiting for each element of F to reach the state 'finished'. An error results if any element of F has NumOutputArguments less than the requested number of outputs.

When F is a vector of FevalFutures, each output argument is formed by concatenating the corresponding output arguments from each future in F. An error results if these outputs cannot be concatenated. To avoid this error, set the 'UniformOutput' option to false.

[B1,B2,...,Bn] = fetchOutputs(F,'UniformOutput',false) requests that fetchOutputs combine the future outputs into cell arrays B1,B2,...,Bn. The outputs of F can be of any size or type.

After the call to fetchOutputs, all futures in F have their 'Read' property set to true. fetchOutputs returns outputs for all futures in F regardless of the value of each future’s 'Read' property.


Create an FevalFuture, and fetch its outputs.

f = parfeval(@rand,1,3);
R = fetchOutputs(f)
0.5562    0.6218    0.3897
0.0084    0.4399    0.2700
0.0048    0.9658    0.8488

Create an FevalFuture vector, and fetch all its outputs. For efficiency, preallocate an array of future objects before.

F(1:10) = parallel.FevalFuture;
for idx = 1:10
    F(idx) = parfeval(@rand,1,1,10); % One row each future
R = fetchOutputs(F); % 10-by-10 concatenated output
Introduced in R2013b