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

    MATLABdude

    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):
    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 [Broken]
     
    Last edited by a moderator: May 4, 2017
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook