필터 지우기
필터 지우기

parfor - how do I "slice" a variable? Can I?

조회 수: 19 (최근 30일)
Michael
Michael 2011년 11월 25일
I have a parfor loop that takes one row of a matrix and uses it for calculations.
I therefore am getting errors since I am calling this variable inside the iteration by writing "b = B(i,:)" to get the ith row. What do I do? I understand the problem, each worker is having to read B to find what b is, but I have no clue what to do to fix it or if anything even can be fixed.
Thanks for any help Mike
  댓글 수: 2
Daniel Shub
Daniel Shub 2011년 11월 26일
What error are you getting? I don't see why
b = B(i, :)
would cause an error, unless you are running out of memory.
Edric Ellis
Edric Ellis 2011년 11월 28일
Any chance you could post a self-contained example? "B(i,:)" should allow the variable B to be sliced, unless you're using B in some other way.

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

답변 (1개)

Hin Kwan Wong
Hin Kwan Wong 2011년 11월 28일
Make sure the following requirements are satisfied:
  • Type of First-Level Indexing — The first level of indexing is either parentheses, (), or braces, {}.
  • Fixed Index Listing — Within the first-level parenthesis or braces, the list of indices is the same for all occurrences of a given variable.
  • Form of Indexing — Within the list of indices for the variable, exactly one index involves the loop variable.
  • Shape of Array — In assigning to a sliced variable, the right-hand side of the assignment is not [] or '' (these operators indicate deletion of elements).
For exacmple, you might have other instances where B is referenced with different indices not as B(i,:) (point 2)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by