Indexed deletion with an empty index transforms a matrix into a row vector since R2016a
Mostrar comentarios más antiguos
When using indexed deletion on a matrix, this matrix is ALWAYS transformed into a row vector, independent if the empty index is an "1x0" empty double column OR row vector.
This behavior originated in R2016a and can be reproduced by the following commands:
>> A = rand(2)
A =
0.4218 0.7922
0.9157 0.9595
Create an empty index:
>> ind = 1:0
ind =
1×0 empty double row vector
Use logical indexing:
>> A(ind)
ans =
1×0 empty double row vector
Performing indexed deletion using the the empty index creates a row-vector, even if the empty index is a column vector
>> A(ind) = []
A =
0.4218 0.9157 0.7922 0.9595
>> A(transpose(ind)) = []
A =
0.4218 0.9157 0.7922 0.9595
As a comparison, the output of the same commands in MATLAB R2015b looks like:
>> A = rand(2)
A =
0.8147 0.1270
0.9058 0.9134
>> A(1:0) = []
A =
0.8147 0.1270
0.9058 0.9134
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Matrix Indexing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!