clusterHost = 'hound.sharcnet.ca';
remoteDataLocation = '/work/jemmyhu/matlab';

% Create a job scheduler / manager object:
sched = findResource('scheduler', 'type', 'generic');

% Use a local directory as the DataLocation
set(sched, 'DataLocation', 'C:\Temp');

set(sched, 'ClusterMatlabRoot', '/opt/sharcnet/matlab/R2010b');
set(sched, 'GetJobStateFcn', @getJobStateFcn);
set(sched, 'DestroyJobFcn', @destroyJobFcn);
        
set(sched, 'HasSharedFilesystem', false);
set(sched, 'ClusterOsType', 'unix');

% If you want to run parallel jobs, you must specify a ParallelSubmitFcn
set(sched, 'ParallelSubmitFcn', {@parallelSubmitFcn, clusterHost, remoteDataLocation});

% Create a Job Scheduler object
numprocs = 4
pjob = createParallelJob(sched)
set(pjob,'MaximumNumberOfWorkers',numprocs)
set(pjob,'MinimumNumberOfWorkers',numprocs)

% We need to include this file on the cluster
set(pjob, 'FileDependencies', {'paralleltestfunction.m'})

% Create and submit the task, wait for results
t = createTask(pjob, @paralleltestfunction, 1, {})
submit(pjob)
waitForState(pjob)
results = getAllOutputArguments(pjob)
y = results{1}

destroy(pjob);
