While using parfor
in MATLAB using cell arrays I stepped into a problem where I can't see any difference from working example code and my buggy line!
The modification of data can be done indipendently for each worker and I wanted to use the slicing of variables, like shown in MathWorks Blog
A3 = cell(10,1);
parfor ix = 1:10
for jx = 1:10
A3{ix}(jx) = ix + jx;
end
end
A3 = cell2mat(A3);
Im doing the exactly same first level indexing like in the example, but MATLAB can't classify it.
I want certain lines to be deleted: There are file Files with each lines Lines that are compared against some values in (for simplicity not shown) other loops. For each file a worker will be assigned.
parfor file=1:length(data(:,1))
line= 1;
length_line = length(data{file,1}(:,1));
while line <= length_line && ... && ...
% some more loops
if (...)
data{file,1}(line,:) = [];
length_line= length_line - 1;
end
% end of some more loops
line= line + 1;
end
end
% data will be returned
I don't see why it should not work! What i took into account:
data
will be modified so that each workers modification has no cross influence to others ( deleted lines are only a subset part of actual worker data)data{file,1}
)data{file,1}(line,:)= []
runs without Matlab warnings.output = mlint('myFile.m')
but it doesn't show me any useful hints.Just this single line is breaking up everything. But I really need this command to work. Any hints / workarounds?
Your code is incomplete, I did not try it out, but this should fix it:
parfor file=1:length(data(:,1))
line= 1;
length_line = length(data{file,1}(:,1));
dataslice=data{file,1}
while line <= length_line && ... && ...
% some more loops
if (...)
dataslice(line,:) = [];
length_line= length_line - 1;
end
% end of some more loops
line= line + 1;
end
data{file,1}=dataslice
end
% data will be returned
If this does not help, please update your question and provide a reproducable example (initialisation of all variables, complete code)