MATLAB Creating Tasks while Passing in multiple Matrix Arguments per task

1 次查看(过去 30 天)
I'm trying to parallelize a job in Matlab. I have a large set of matrices that I would like to pass to a function, which then returns a vector. What I would like to do is to assign a subset of the matrices to each task and then return their outputs. I have been able to get the code working where each task is assigned only 1 matrix to pass, but when I try to assign multiple matrices to each task, I'm getting the Too Many Arguments error.
From reading the documentation, on createTask, I suspect that the structure that I'm using to pass in the matrices is the problem.
numTasks=4;
%Setting up the splitting of my 60 matrices among 4 tasks.
[xSplit, numTasks] =pctdemo_helper_split_vector(linspace(1,60,60, numTasks));
%XSplit shows the splits of the numbers 1-60 to each of 4 cells in XSplit
celldisp(xSplit);
%Substituting in my matrices for the indices in XSplit
for i=1:numTasks
xSplitVec=xSplit{i};
for j=1:length(xSplitVec);
%SCov is an array where I have collected all my matrices
xSplitMat{i,j}=SCov_array(:,:, xSplitVec(j));
end
end
parallel.defaultClusterProfile('local');
c = parcluster();
job=createJob(c);
for i=1:numTasks
xThis=xSplitMat(i,:);
%@Norm1MinVar_par is my function, which takes matrices and returns a vector
createTask(job, @Norm1MinVar_par, 1, xThis);
end
submit(job);
wait(job);
y=fetchOutputs(job);
delete(job);
cat(2, y{:})
My code follows the example from Dividing Tasks. (Also posted in StackExchange.)
  1 个评论
Edric Ellis
Edric Ellis 2016-2-2
It's not clear what the problem here is. Does that code fail at the createTask line? The syntax of createTask that you're using there appears to be fine. The number of elements in the cell array xThis should match the expected number of inputs to Norm1MinVar_par.

请先登录,再进行评论。

回答(0 个)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by