accumarray error: Index into matrix must be positive
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Jack Ie
le 4 Avr 2016
Modifié(e) : Walter Roberson
le 4 Avr 2016
G=[0 1 ; 0 2 ; 1 2];
adj=accumarray(G,1,[],[],0,true);
error: Index into matrix must be positive.
0 commentaires
Réponse acceptée
Star Strider
le 4 Avr 2016
What I do in situations such as yours is to add 1 to the minimum value (here 0) of the index array:
G=[0 1 ; 0 2 ; 1 2];
adj=accumarray(G+1,1,[],[],0,true);
That solves the immediate problem. You can make adjustments in other parts of your code afterwards.
0 commentaires
Plus de réponses (2)
Voir également
Catégories
En savoir plus sur Data Types dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!