MATLAB: Double indexing

MATLABvector

Hello,
is it possible to do double or multiple indexing in matlab? E.g.
>> v = [1,2,5,7,9]
v =
1 2 5 7 9
>> v(1:4)
ans =
1 2 5 7
>> v(1:4)(2:3)
ans =
2 5
The first index create a new vector and the second index creates a new vector out of the newly created one. It is common in other languages, and it helps to avoid defining temp variables.
Cheers, Frank

Best Answer

The closest you can get is
subsref(V(1:4), struct('type', '()', 'subs', 2:3)))
You can follow {} referencing by () referencing, {}(), but you cannot use ()() or (){} or ().{} or ().(), and you cannot use function(){} or function()() or function().field