Indexing via 3d array changed behaviour 2015a -> 2015b?
1 ビュー (過去 30 日間)
Hi all, just got 2015b, here's a strange one where indexing via a multidimensional array has a differently shaped output to previous versions:
a = 1:10;
b = reshape(4:6,1,1,);
2015a and before:
4 5 6
I searched through the release notes and couldn't find anything that relates to this behaviour change. Did I miss something? Or is this a bug that I should report?
Scott French 2015 年 10 月 20 日
This was an intentional change/bug fix. Prior to R2015b, there was an inconsistency in the MATLAB indexing behavior - if you try your experiment in R2015a, but with the value of "a" being stored in a field of a struct, or an element of a cell, you'd get a different answer:
>> s.a = 1:10
a: [1 2 3 4 5 6 7 8 9 10]
>> b=reshape(4:6, 1, 1, );
4 5 6
It didn't seem reasonable that the same value could be indexed by the same index, but give different results depending on where the value came from. So we changed it to give the same result.
The rule that we apply is, for an expression R(I) where R and I both have only one non-singleton dimension, then the dimensions of the result have the length of I, and the orientation of R.