How to apply function eig to an array of matrices?

조회 수: 3 (최근 30일)
Kaixiang Su
Kaixiang Su 2019년 7월 7일
답변: Bruno Luong 2019년 7월 7일
I am trying to find the eigenvectors and eigenvalues of an array of matrices without doing a for loop. A simple example would be like:
A[:,:,1] = [1,2;3,4]
A[:,:,2] = [3,4;5,6]
...
A[:,:,10] = [19,20;21,22]
And the matrix elements can be arbitrary. My question is whether there is an efficient way to solve the eigen problem of each of these matrices without doing a for loop? Can tips of vectorization help us here?

답변 (2개)

the cyclist
the cyclist 2019년 7월 7일
편집: the cyclist 2019년 7월 7일
cellfun(@eig,A,'UniformOutput',false)
or something like this, will be at the heart of your solution. You might need to read the documentation for cellfun and/or eig to get exactly the output you want.

Bruno Luong
Bruno Luong 2019년 7월 7일
If your matrices is 2x2 or 3x3 you can use this FEX for eigen values, then this one for engen vectors.

카테고리

Help CenterFile Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by