Array indexing output size not consisnent
Réponses (1)
0 votes
If idx is not a 1-D vector, then size(idx) returns an array with the lengths in each direction. A(idx) returns a column vector because if idx was such that it picked out only some of the elements of A, then you'd have an output that has "holes" in it, for example 3 elements might be selected on row 1 and 8 elements selected on row 2. Arrays must be rectangular (all rows have the same number of elements), so to get a result, they must just list all selected in a single 1-D vector.
It's not a bug, it's a feature. In time you will not only get used to it but come to appreciate and even rely on it.

Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!