Domanda

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?

È stato utile?

Soluzione

You can convert the index vector to a cell first:

A(num2cell(idx){:})

but there is probably a more elegant solution to that.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top