필터 지우기
필터 지우기

Cannot get figure using parfor in a loop

조회 수: 7 (최근 30일)
Jiawei Xu
Jiawei Xu 2023년 5월 11일
답변: Manoj Mirge 2023년 5월 15일
Hi,
I want to define the color of each arrow with function quiver3, but I have a large number of data(double 83041*1), so I used parfor as below:
But no figure returned, it works well when I use just for for loops.
Regards!
h = figure(1);
parfor n = 1:nPart
disp(n);
col = colors(vv(n),:);
quiver3(x_s(cal_step,n),y_s(cal_step,n),z_s(cal_step,n),u(del_step,n),v(del_step,n),w(del_step,n),10,'Color',[col(1),col(2),col(3)]);
end

답변 (1개)

Manoj Mirge
Manoj Mirge 2023년 5월 15일
It is not possible to plot to the display inside any parallel construct. The workers are in separate processes that do not have access to the graphics subsystem.
You would need to either calculate all the data in the “parfor” and then do the plotting after the “parfor” or you can plot in parfor,” and then you can use saveas to save it to a file.
Below, I have attached link to a MATLAB Answers thread that discusses an issue similar to yours:
You can read more about “saveas” in the below attached link:

카테고리

Help CenterFile Exchange에서 Parallel for-Loops (parfor)에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by