Parallel pool: Conversion to double from cell is not possible
4 views (last 30 days)
Show older comments
Hello guys!
i'm trying to solve this problem. I started this loop (where B is a table).
parfor i=1:116676;
if G(i)== 1;
S(i,:)= table2cell(B(i,:));
end
end
My problem is that is i run the loop without "parfor" it works... but if i use "parfor" the cicle doesn't works and Matlab told me:
Conversion to double from cell is not possible.
What can i do for solve this problem?
thank you :D
0 Comments
Answers (1)
Edric Ellis
on 7 Feb 2017
The problem here is that you haven't pre-allocated S, and unfortunately this doesn't quite work out correctly in parfor. The simple fix is to pre-allocate S to be a cell array of the correct size.
B = table(rand(10,1), rand(10,1));
G = rand(height(B),1) > 0.5;
S = cell(height(B), width(B));
parfor i=1:height(B)
if G(i)== 1
S(i,:)= table2cell(B(i,:));
end
end
0 Comments
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!