Consider the following simple example.
test=[1,2,3;4,5,6];
size(test)
we will recieve 2 3
, which means test
's dimension is 2x3. I expect 2 3
being a (1x2)-array data itself. So it should be possible to ask size(test)(2)
, but then you will get an error; Error: Invalid array indexing.
. Using size(test)(1,2)
also raises the same error message. However, if you save this size
's result by a name, then you won't get an error using the indexing and the name.
test2=size(test);
test2(2) % you will get 3.
test2(1,2) % you will get 3.
Sometimes you may only need this dimension once and saving it is a waste of memory. Why isn't it possible to ask size(test)(2)
but it is possible to ask test2(2)
?