Hey,
I have trouble using histogram in a parfor-loop. Below is a minimal-working-example of my problem:
parfor idx = 1:2
x = randn(1,50*idx);
f = figure()
histogram(x,'Normalization','pdf')
drawnow
end
This gives me the response:
Error using histogram (line 140)
Transparency violation error.
See Parallel Computing Toolbox documentation about Transparency
Error in untitled6 (line 3)
parfor idx = 1:2
I get the error with both R2018a and R2018b
Best regards,

 채택된 답변

Edric Ellis
Edric Ellis 2019년 5월 1일

1 개 추천

Unfortunately, histogram tries to extract the name of the input variable, and this causes the transparency violation. You can work around this problem by hiding the call to histogram inside an anonymous function, like this:
histFcn = @(x) histogram(x, 'Normalization', 'pdf');
parfor idx = 1:2
x = rand(1, 50*idx);
histFcn(x);
end

댓글 수: 1

I figured might be caused by some eval-like function.
For whom it may concern, it also works if you to include multiple variable inputs to the histogram function, as an example;
histFcn = @(x,c) histogram(x, 'Normalization', 'pdf', 'FaceColor', c);
Thanks Edric!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Histograms에 대해 자세히 알아보기

제품

릴리스

R2018b

질문:

2019년 4월 30일

댓글:

2019년 9월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by