Parfor+for+if+if How to calculate variable form last if

1 次查看(过去 30 天)
See my code
parfor i = 1:n
for j=1:m
if some_condition(i)
if some_condition(i)
t=do_something(i);
b = [b;t];
end
end
end...
end
I want all b values to get out from the par

采纳的回答

Walter Roberson
Walter Roberson 2024-4-30
b = [];
parfor i = 1:n
bt = [];
for j=1:m
if some_condition(i)
if some_condition(i)
t=do_something(i);
bt = [bt;t];
end
end
end...
b = [b, bt];
end
  5 个评论
Walter Roberson
Walter Roberson 2024-4-30
m = 7;
n = 3;
b = [];
parfor i = 1:n
bt = [];
for j=1:m
if rand > 0.5
if rand > 0.5
t=i;
bt = [bt;t];
end
end
end
b = [b; bt];
end
b
b = 7x1
1 1 2 2 3 3 3
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Parallel for-Loops (parfor) 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by