Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Need help on Matlab code

  1. Jul 24, 2009 #1
    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
  2. jcsd
  3. Jul 25, 2009 #2


    User Avatar
    Science Advisor

    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):

    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.

    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:

    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 [Broken]
    Last edited by a moderator: May 4, 2017
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook