Вопрос

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?

Это было полезно?

Решение

You can convert the index vector to a cell first:

A(num2cell(idx){:})

but there is probably a more elegant solution to that.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top