Matlab Code Help: Read Sparse Matrix, Calculate Eigenvalues

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 5K views
confi999
Messages
18
Reaction score
0
Hello.
Can anyone help me in producing a Matlab code that will read a sparse matrix and then calculate the eigenvalues of it, show the sparsity pattern of it etc. I have the the sparse matrix data in compressed sparse row (CSR), compressed sparse column (CSC) formats and also in Co-ordinate format. But as co-ordinate format takes large storage I would prefer CSR or CSC format. I usually use Fortran but Matlab has some readily available mathematical functions and therefore I need this MATLAB code. Any support on Matlab code is highly appreciated. Thank you
 
Physics news on Phys.org
Welcome to PhysicsForums!

The online MATLAB documentation is really good (the in-program one is decent, but, of course, it's within the MATLAB text environment). For instance, you can bring up help on the eig eigenvalue function using:
>> help eig

Or, go to the more complete documentation at the Mathworks website (note the note regarding sparse matrices):
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/eig.html

If they're stored in text format, my first inclination is that you'd probably need the dlmread (or more likely, C-style fscanf) function just to get the numbers into MATLAB. You'll probably still need to write a script to handle your CSR and CSC formats.
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/dlmread.html
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/fscanf.html

I've never worked with sparse matrices (not as anything different from regular matrices, at any rate), and obviously, not within the MATLAB environment. Just from reading, the sparse command looks to be able to inflate / compress sparse matrices:
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/sparse.html

However, if there's anything to be found, it might be found by starting here:
http://www.mathworks.com/access/helpdesk/help/techdoc/math/f6-9182.html
 
Last edited by a moderator: