Borrar filtros
Borrar filtros

How to store results in a structure, by using parfor loop ?

17 visualizaciones (últimos 30 días)
combinaison = struct();
parfor calcul = 1:2
coco = struct();
combinaison(calcul).modele = 5;
coco.modele.CL(1).branche(2).type = combinaison(calcul).modele;
disp(coco.modele.CL(1).branche(2).type);
end
Hi everyone,
I cannot store results in the "combination" structure for loop exit analysis...
Thank you in advance for your help !

Respuesta aceptada

Max Heimann
Max Heimann el 13 de En. de 2022
Matlab does not support dynamically changing array sizes in parfor loops.
You need to preallocate your struct. Try this:
N = 2;
combinaison = repmat(struct(), N, 1 );
parfor calcul = 1:N
coco = struct();
combinaison(calcul).modele = 5;
coco.modele.CL(1).branche(2).type = combinaison(calcul).modele;
disp(coco.modele.CL(1).branche(2).type);
end

Más respuestas (0)

Categorías

Más información sobre Structures en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by