parfor - how do I "slice" a variable? Can I?
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Daniel Shub
le 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
le 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.
Réponses (1)
Hin Kwan Wong
le 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)
0 commentaires
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!