Question

In my script I am creating an array, the number of dimensions of which are not known in advance. I want to get a certain sub-matrix from the array. Typically with an array of a known number of dimensions I would just write array(i1, i2, i3, ... iN, :, :). However, the indices are contained in an array I = [i1, i2, i3, ... iN). How do I accomplish this?

Was it helpful?

Solution

You can convert the index vector to a cell first:

A(num2cell(idx){:})

but there is probably a more elegant solution to that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top