Filter löschen
Filter löschen

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

19 Ansichten (letzte 30 Tage)
Michael
Michael am 25 Nov. 2011
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 Kommentare
Daniel Shub
Daniel Shub am 26 Nov. 2011
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 am 28 Nov. 2011
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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Hin Kwan Wong
Hin Kwan Wong am 28 Nov. 2011
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)

Kategorien

Mehr zu Parallel for-Loops (parfor) finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by