Skip to Main Content Skip to Search
Product Documentation

dfeval - Evaluate function using cluster

Syntax

[y1,...,ym] = dfeval(F, x1,...,xn)
y = dfeval( ..., 'P1',V1,'P2',V2,...)
[y1,...,ym] = dfeval(F, x1,...,xn, ... 'configuration', 'ConfigurationName',...)

Arguments

F

Function name, function handle, or cell array of function names or handles.

x1, ..., xn

Cell arrays of input arguments to the functions.

y1, ..., ym

Cell arrays of output arguments; each element of a cell array corresponds to each task of the job.

'P1', V1, 'P2', V2, ...

Property name/property value pairs for the created job object; can be name/value pairs or structures.

Description

[y1,...,ym] = dfeval(F, x1,...,xn) performs the equivalent of an feval in a cluster of machines using Parallel Computing Toolbox software. dfeval evaluates the function F, with arguments provided in the cell arrays x1,...,xn. F can be a function handle, a function name, or a cell array of function handles/function names where the length of the cell array is equal to the number of tasks to be executed. x1,...,xn are the inputs to the function F, specified as cell arrays in which the number of elements in the cell array equals the number of tasks to be executed. The first task evaluates function F using the first element of each cell array as input arguments; the second task uses the second element of each cell array, and so on. The sizes of x1,...,xn must all be the same.

The results are returned to y1,...,ym, which are column-based cell arrays, each of whose elements corresponds to each task that was created. The number of cell arrays (m) is equal to the number of output arguments returned from each task. For example, if the job has 10 tasks that each generate three output arguments, the results of dfeval are three cell arrays of 10 elements each. When evaluation is complete, dfeval destroys the job.

y = dfeval( ..., 'P1',V1,'P2',V2,...) accepts additional arguments for configuring different properties associated with the job. Valid properties and property values are

[y1,...,ym] = dfeval(F, x1,...,xn, ... 'configuration', 'ConfigurationName',...) evaluates the function F in a cluster by using all the properties defined in the configuration ConfigurationName. The configuration settings are used to find and initialize a scheduler, create a job, and create tasks. For details about defining and applying configurations, see Cluster Profiles. Note that configurations enable you to use dfeval with any type of scheduler.

Note that dfeval runs synchronously (sync); that is, it does not return the MATLAB prompt until the job is completed. For further discussion of the usage of dfeval, see Evaluate Functions Synchronously.

Examples

Create three tasks that return a 1-by-1, a 2-by-2, and a 3-by-3 random matrix.

y = dfeval(@rand,{1 2 3})
y = 
    [    0.9501]
    [2x2 double]
    [3x3 double]

Create two tasks that return random matrices of size 2-by-3 and 1-by-4.

y = dfeval(@rand,{2 1},{3 4});
y{1}
ans =
    0.8132    0.1389    0.1987
    0.0099    0.2028    0.6038
y{2}
ans =
    0.6154    0.9218    0.1763    0.9355

Create two tasks, where the first task creates a 1-by-2 random array and the second task creates a 3-by-4 array of zeros.

y = dfeval({@rand @zeros},{1 3},{2 4});
y{1}
ans =
    0.0579    0.3529
y{2}
ans =
     0     0     0     0
     0     0     0     0
     0     0     0     0

Create five random 2-by-4 matrices using MyJobManager to execute tasks, where the tasks time out after 10 seconds, and the function will stop if an error occurs while any of the tasks are executing.

y = dfeval(@rand,{2 2 2 2 2},{4 4 4 4 4}, ...
'JobManager','MyJobManager','Timeout',10,'StopOnError',true);

Evaluate the user function myFun using the cluster as defined in the configuration myConfig.

y = dfeval(@myFun, {task1args, task2args, task3args}, ...
    'configuration', 'myConfig', ...
    'FileDependencies', {'myFun.m'});

See Also

dfevalasync | feval | findResource

  


Free Parallel Computing Interactive Kit

See how to solve large problems with minimal effort and reduce simulation time.

Get free kit

Trials Available

Try the latest versions of parallel computing products.

Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS