i'm sure there's a compact, efficient way to do this, but it's eluding me and my google-fu is failing:
give a n-dimensional matrix A (n unknown apriori), and a user specified dimension to operate on, return the first 'part' of the array for that dimension, preserving shape:
e.g, for a 3D array, dim 2:
B = A(:,1,:)
for dim 3:
B = A(:,1,:)
for a 4D array, dim 2:
B = A(:,1,:,:)
for dim 4:
etc.
what's an efficient way to extract that subarray for any number of dimensions? i assume I could do something clever directly with subsasgn and expanding a cell array of some number of ':' with {:}, but i'm sure I'm missing something cleaner, no?
(does not need to be matlab compatible)