Problems using parfor loop

1 ビュー (過去 30 日間)
Amit Chakraborty
Amit Chakraborty 2022 年 3 月 7 日
編集済み: Davide Masiello 2022 年 3 月 7 日
% It would have been very helpful for if get some probable solution for the
% following problem I am facing. Thanks in Advance.
%% Problem 1 : Error => Idx is not available after parfor loop ( As a result, TT showing me undefined )
AA = [4 5 6];
parfor r = 1:5
[Idx]= max(AA);
end
TT = Idx;
%% Problem 2: Error => parfor loop cannot run due to the way variable "coords" used.
parfor r = 1:5
coords(r,:) = "Some Arbitary Function" % I can not share the real code here
end

回答 (1 件)

Davide Masiello
Davide Masiello 2022 年 3 月 7 日
編集済み: Davide Masiello 2022 年 3 月 7 日
For the first problem, write this
AA = [4 5 6];
parfor r = 1:5
Idx(r)= max(AA);
end
TT = Idx;
Regarding the second one, it might be due to the nature of the output of the function you cannot share.

カテゴリ

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by