フィルターのクリア

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

17 ビュー (過去 30 日間)
Michael cohen
Michael cohen 2022 年 1 月 13 日
コメント済み: Michael cohen 2022 年 1 月 13 日
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 !

採用された回答

Max Heimann
Max Heimann 2022 年 1 月 13 日
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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by