MATLAB Matlab Code Help: Read Sparse Matrix, Calculate Eigenvalues

Click For Summary
A user seeks assistance in creating MATLAB code to read a sparse matrix in CSR or CSC formats and calculate its eigenvalues while displaying its sparsity pattern. They prefer these formats due to storage efficiency compared to the Co-ordinate format. Recommendations include utilizing MATLAB's built-in functions, such as 'eig' for eigenvalue calculations and 'sparse' for handling sparse matrices. For importing data, functions like 'dlmread' or 'fscanf' are suggested for reading text-based matrix data. The discussion emphasizes the availability of comprehensive MATLAB documentation, which can aid in understanding these functions and their applications for sparse matrices.
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:

Similar threads

  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 41 ·
2
Replies
41
Views
10K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 4 ·
Replies
4
Views
11K