Matlab Code Help: Read Sparse Matrix, Calculate Eigenvalues

Click For Summary
SUMMARY

This discussion focuses on creating MATLAB code to read sparse matrices in CSR (Compressed Sparse Row) and CSC (Compressed Sparse Column) formats and calculate their eigenvalues. Users are directed to MATLAB's built-in functions such as eig for eigenvalue computation and dlmread or fscanf for reading matrix data. The sparse command is highlighted for managing sparse matrices. The MathWorks documentation is recommended as a comprehensive resource for further assistance.

PREREQUISITES
  • Familiarity with MATLAB programming environment
  • Understanding of sparse matrix formats (CSR and CSC)
  • Knowledge of eigenvalue calculations in linear algebra
  • Basic skills in reading data files in MATLAB
NEXT STEPS
  • Research how to implement the eig function for eigenvalue calculations in MATLAB
  • Learn about the dlmread and fscanf functions for importing data
  • Explore the sparse command for manipulating sparse matrices
  • Review the MathWorks documentation on sparse matrices for advanced techniques
USEFUL FOR

Mathematics students, data scientists, and engineers working with MATLAB who need to handle sparse matrices and perform eigenvalue computations efficiently.

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
4K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
7K
  • · 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