How do I clear the command window in a parfor loop?

4 ビュー (過去 30 日間)
Jakob Sievers
Jakob Sievers 2014 年 11 月 5 日
編集済み: Sean de Wolski 2014 年 11 月 5 日
It seems that clearing the command window (clc) is not possible in parfor. How do I achieve this then? I.e. i'd like this loop:
N=50;
parfor ii=1:N
rv=rand(1);
pause(rv)
clc
disp(rv)
end
To behave similarly to:
N=50;
for ii=1:N
rv=rand(1);
pause(rv)
clc
disp(rv)
end

回答 (1 件)

Sean de Wolski
Sean de Wolski 2014 年 11 月 5 日
編集済み: Sean de Wolski 2014 年 11 月 5 日
The clc command does clear the command window of the worker it was run on, not the client session.
One possible workaround would be to use fprintf with \b to "erase" what you've done essentially updating the same few characters. However, I'm not sure the how the command window would react to multiple workers concurrently trying to access it.

カテゴリ

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