Let's say I have a 3x3x3 Matlab array with members 1 to 27
a=reshape(1:27, [3 3 3])
I would like to create a subset of this with a syntax like
b=a(range1,range2,range3)
where for range1=range2=range3=1:2 I would get the members b(1,1,1) and b(2,2,2). i.e
b= [1 14]
Is it possible to do this just with indexing and without any functions (e.g. diag)? Thanks...
b=a(sub2ind(size(a),range1,range2,1:3)). That's why I am looking for doing it only with the indices...