Filter löschen
Filter löschen

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

17 Ansichten (letzte 30 Tage)
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 !

Akzeptierte Antwort

Max Heimann
Max Heimann am 13 Jan. 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

Weitere Antworten (0)

Kategorien

Mehr zu Structures finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by