I want to do some numerical examples solving large sparse linear system Ax=b. And I want to use some data from Maltab itself because this experiments are easily reproduced any time using Matlab. For example,

load west0479.mat
A = west0479;
b = sum(A,2);

Using these codes, I can obtain a sparse matrix linear system. I want to ask whether there are some other sparse matrix data in Matlab? If so, please give me some examples.

  • $\begingroup$ do you mean other .mat files with sparse matrices that come right away with every distribution of Matlab? $\endgroup$ – Anton Menshov Nov 30 '19 at 1:02
  • $\begingroup$ yes, any else .mat file representing matlab sparse matrix? Like west0479.mat above. Thanks. $\endgroup$ – sunshine Nov 30 '19 at 2:44

There are many sparse matrices in Matrix Market

A visual repository of test data for use in comparative studies of algorithms for numerical linear algebra, featuring nearly 500 sparse matrices from a variety of applications, as well as matrix generation tools and services.

Use Matrix Market in conjunction with MM_TO_MSM: Matrix Market File to MATLAB Sparse Matrix.

MM_TO_MSM, a MATLAB library which reads the information stored in a Matrix Market file, and sets it up as a MATLAB sparse matrix.

Matrix Market includes Matlab Procedures for Reading/Writing Harwell-Boeing Files

The Berkeley Benchmarking and Optimization (BeBOP) Group has developed a library and standalone utility for converting between Harwell-Boeing, Matrix Market, and MATLAB sparse matrix formats.

which will allow you to import the Harwell-Boeing collection of matrices from https://math.nist.gov/MatrixMarket/data/Harwell-Boeing/

| cite | improve this answer | |
  • $\begingroup$ Thanks very much. Except the matrix market, any else .mat file representing matlab sparse matrix which is built-in matlab software? Like west0479.mat above. Thanks. $\endgroup$ – sunshine Nov 30 '19 at 2:46
  • $\begingroup$ @Federico Poloni provided one in his answer. Also note, that although not "built-in" to MATLAB, my answer links to how to access the Harwell-Boeing collection, most of which is sparse. $\endgroup$ – Mark L. Stone Nov 30 '19 at 12:12

A = bucky(), for instance.  

| cite | improve this answer | |
  • $\begingroup$ Thanks for your reply, the bucky is indeed a function .m file instead of a .mat data file. I have found that there is no other sparse matrix .mat data file in matlab built-in software. see the below from a professor's answer. @Mark L. Stone $\endgroup$ – sunshine Dec 1 '19 at 1:07

Below is from a Professor's answer.

No. It is straightforward to check this. west0479 resides in the demos folder where all such samples are kept.

>> which west0479.mat
C:\Program Files\MATLAB\R2019b\toolbox\matlab\demos\west0479.mat

We can get a list of the .mat files in this folder which might contain sparse matrices.

>> files = dir(fullfile(matlabroot,'toolbox','matlab','demos','*.mat'))

files = 

  41×1 struct array with fields:


Each of these files can be loaded and checked for sparse variables. Let's make an array from these checks and use it to index the list of files, so only files containing sparse matrices are returned:

>> files(arrayfun(@(f) any(structfun(@issparse,load(fullfile(f.folder,f.name)))),files))

ans = 

  struct with fields:

       name: 'west0479.mat'
     folder: 'C:\Program Files\MATLAB\R2019b\toolbox\matlab\demos'
       date: '14-Mar-2004 15:32:24'
      bytes: 12580
      isdir: 0
    datenum: 7.3202e+05

west0479.mat is the only one.

| cite | improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.