Help with turning a while loop into a parfor
Show older comments
I am trying to change my code from using a single computer to a cluster (already set up) bu tam struggling to turn an area of code from using a while to a parfor. The code is as follows-
bigBoxD = cell(1);
bbDCount = 1;
i = 1;
data = sortrows(data,'date','ascend');
while i <= height(data)
%create an empty table with headers
subset = data;
subset(:,:) = [];
%populate subset based on date
s1 = data.date(i);
tempcount = 1;
while data.date(i) == s1 && i < height(data)
subset(tempcount,:) = data(i,:);
i = i + 1;
tempcount = tempcount + 1;
end
%Stores subset in cell array
if isempty(subset)
i = i + 1;
else
bigBoxD{bbDCount} = subset;
bbDCount = bbDCount + 1;
i = i + 1;
end
end
I understand that the issue is in how I'm storing data in the "bigBoxD" variable, which after this loop goes for further processing. Is there a way I can continue to store the data in this cell array and use a parfor loop to generate it?
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!