% Specify a cluster environment and use a local folder as the JobStorageLocation
cluster = parallel.cluster.Generic( 'JobStorageLocation', 'C:\Temp' );

% Specify File system and MATLAB Root
set(cluster, 'HasSharedFilesystem', false);
set(cluster, 'ClusterMatlabRoot', '/opt/sharcnet/matlab/R2012a');
set(cluster, 'OperatingSystem', 'unix');

% Define the additional inputs to the submit functions
clusterHost = 'hound.sharcnet.ca';
remoteJobStorageLocation = '/work/jemmyhu/matlab';

% The IndependentSubmitFcn must be a MATLAB cell array that includes the two additional inputs
set(cluster, 'IndependentSubmitFcn', {@independentSubmitFcn, clusterHost, remoteJobStorageLocation});
set(cluster, 'GetJobStateFcn', @getJobStateFcn);
set(cluster, 'DeleteJobFcn', @deleteJobFcn);


% Create a job object:
j = createJob(cluster)

% Create independent tasks
createTask(j, @sum, 1, {[1 1]});
createTask(j, @sum, 1, {[2 2]});
createTask(j, @sum, 1, {[3 3]});
% where sum is the command name, 1 is the number of return values and 
% the rest is the argument list that is to be passed to sum().

% Submit the job - this is non blocking
submit(j)

% Retrieve the job
wait(j)
results = fetchOutputs(j)