Borrar filtros
Borrar filtros

Parallel pool: Conversion to double from cell is not possible

17 visualizaciones (últimos 30 días)
Light.16
Light.16 el 6 de Feb. de 2017
Respondida: Edric Ellis el 7 de Feb. de 2017
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

Respuestas (1)

Edric Ellis
Edric Ellis el 7 de Feb. de 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

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by