Borrar filtros
Borrar filtros

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

17 visualizaciones (últimos 30 días)
Michael
Michael el 25 de Nov. de 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 comentarios
Daniel Shub
Daniel Shub el 26 de Nov. de 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 el 28 de Nov. de 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.

Iniciar sesión para comentar.

Respuestas (1)

Hin Kwan Wong
Hin Kwan Wong el 28 de Nov. de 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)

Categorías

Más información sobre Parallel for-Loops (parfor) en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by