필터 지우기
필터 지우기

parfor shows an empty figure

조회 수: 1 (최근 30일)
J T
J T 2019년 12월 17일
댓글: J T 2019년 12월 17일
Hello,
I am trying to use parfor to plot some filled rectangles with the following codes for some data x,y,f and a parameter l, this code works fine on serial for loop, when I tried to do it with parfor, it returns an empty figure, how should I resolve this? Thank you!
figure();
for i = 1:length(f)
if f(i)==1
fill( [x(i) x(i)+l x(i)+l x(i)],...
[y(i) y(i) y(i)+l y(i)+l],[0 91 187]/255,'LineStyle','none');hold on;
end
end
  댓글 수: 6
Adam Danz
Adam Danz 2019년 12월 17일
편집: Adam Danz 2019년 12월 17일
" Btw, why is l a bad variable name"
  • l looks like 1. When a human is reading your code, it's very easy to misinterpret y(i)+l as adding 1
  • Single character variable names are often used in loops (for i = 1:10) and to represent common variables such as p-values (p = anova1(...)) but in general, it's best to use variable names with more than 1 character.
  • When using the editor, if you select a variable you'll notice that all instances of that variable within the same function are highlighted. With a variable name as narrow as l you lose the ability to quickly see all of those instances.
  • It's very easy to accidentally type a single-character variable name via a typo. It's much more difficult to accidentally type LValue than l.
J T
J T 2019년 12월 17일
Thanks! Good to learn!

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Parallel Server에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by