Is there a way to plot to a file while in a parfor loop?

28 ビュー (過去 30 日間)
Mark
Mark 2013 年 3 月 27 日
編集済み: Mathias 2019 年 2 月 7 日
Hello,
I have a MATLAB program I'm running in parallel. I understand that I can't use a worker process to plot to the screen. But, I'm curious, is it possible to use a worker process to plot directly to a file?
Thanks,
Mark

採用された回答

Jing
Jing 2013 年 3 月 28 日
編集済み: Jing 2013 年 3 月 28 日
You can plot in parfor, it's just you won't see it, but the handle is still there. Then you can use saveas to save it to a file.
parfor i=1:5
figure(i)
plot(rand(i*10,1));
saveas(gcf,['temp' num2str(i) '.jpg']);
end
  3 件のコメント
Yaswanth  Sai
Yaswanth Sai 2018 年 1 月 11 日
Exactly! Thanks again.
Mathias
Mathias 2019 年 2 月 7 日
編集済み: Mathias 2019 年 2 月 7 日
I tried the code, but got the following error:
% Error using validate (line 162)
% Printing of uicontrols is not supported on this platform.
%
% Error in print (line 67)
% pj = validate( pj );
%
% Error in saveas (line 181)
% print( h, name, ['-d' dev{i}] )
%
% Error in Untitled (line 1)
% parfor i=1:5
Using Matlab 2017b. Any solution for this?
Thanks in Advance
Edit: Found another examle of this with figure() instead of figure(var). Thats the solution.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by