## Computational neuroscience - I have a 116x116x226 I need to calculate the eigenvalues for this array can anyone help me?

### Elizabeth Drybrugh (view profile)

on 20 Feb 2018
Latest activity Edited by Andrei Bobrov

### Andrei Bobrov (view profile)

on 20 Feb 2018
I have tried to use eig but doesn't work for 3D arrays. Any help will be greatly appreciated

### Roger Stafford (view profile)

on 20 Feb 2018
Edited by Roger Stafford

### Roger Stafford (view profile)

on 20 Feb 2018

A 3D array is not a matrix, and matrix multiplication is not defined for such arrays. Eigenvalues and eigenvectors are defined in terms of matrix multiplication, and therefore do not have a definition for 3D arrays.
You can, however, find eigenvalues and vectors for each of the 226 layers in your array since each one is a square matrix. That would make sense.

Elizabeth Drybrugh

### Elizabeth Drybrugh (view profile)

on 20 Feb 2018
Ok, cheers for the correction as you can tell my maths is rather rusty. Regardless I have 116 by 116 nodes for 226 subjects and need the values for the 226 subjects. As attached I am interested in these diagonal values on 226 pages... I have tried to simplify the dimensions and look at 226 but I lose some values this way..
cheers, for you help
Roger Stafford

### Roger Stafford (view profile)

on 20 Feb 2018
Yes, each separate 116-by-116 layer of your array is a matrix, and in general will have 116 eigenvalues as well as the same number of eigenvectors, one for each eigenvalue. That will give you a total of 116*226 eigenvalues in general and 116*116*226 components of eigenvectors, but I don't know what you want to do with all of them.
I couldn't understand your "untitled.png" image, and I don't know what you mean by "these diagonal values on 226 pages".
Andrei Bobrov

on 20 Feb 2018

### Andrei Bobrov (view profile)

on 20 Feb 2018
Edited by Andrei Bobrov

### Andrei Bobrov (view profile)

on 20 Feb 2018

[m,n] = size(d);
ii = rem(0:n-1,m)+1 ~= 1;
nn = 1:n;
n1 = nn(ii);
n2 = repmat(1:m,1,ceil(n/m));
n2 = n2(nn);
n2 = n2(1:end-1);
n2 = n2(n2 ~= m);
out = d(sub2ind([m,n],n2,n1));
second variant
[m,n] = size(d);
m2 = m*m;
out = d((m+1:m+1:m2)' + (0 : ceil(n/m)-1)*m2);