フィルターのクリア

show variables in parfor

7 ビュー (過去 30 日間)
Tiki Tiki
Tiki Tiki 2018 年 7 月 18 日
コメント済み: Tiki Tiki 2018 年 7 月 18 日
Hi everyone,
I practice parfor code in help(matlab). i run code but dont know how to show variable in parfor.
parfor i = 1:4
temp = struct();
temp.myfield1 = rand();
temp.myfield2 = i;
end
parfor i = 1:4
temp = struct('myfield1',rand(),'myfield2',i);
end
Thank for helping me.

採用された回答

Walter Roberson
Walter Roberson 2018 年 7 月 18 日
Just display them.
For example,
parfor K = 1 : 20; t = getCurrentTask(); fprintf('task %d got iteration %d\n', t.ID, K); end
output
task 1 got iteration 1
task 2 got iteration 2
task 3 got iteration 4
task 3 got iteration 3
task 4 got iteration 7
task 1 got iteration 10
task 1 got iteration 9
task 1 got iteration 8
task 2 got iteration 13
task 2 got iteration 12
task 2 got iteration 11
task 4 got iteration 6
task 4 got iteration 5
task 1 got iteration 18
task 3 got iteration 15
task 3 got iteration 14
task 2 got iteration 19
task 3 got iteration 20
task 4 got iteration 17
task 4 got iteration 16

その他の回答 (1 件)

Tiki Tiki
Tiki Tiki 2018 年 7 月 18 日
Thank. Actually, my hope is show variable in Workspace. because when i run this code, the result doesnot appear in workspace.
  2 件のコメント
Walter Roberson
Walter Roberson 2018 年 7 月 18 日
If you want to capture the console output of parfor(), then use diary(), or call the parfor() within evalc()
Tiki Tiki
Tiki Tiki 2018 年 7 月 18 日
Thank you.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeParallel for-Loops (parfor) についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by