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.
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:
name
folder
date
bytes
isdir
datenum
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
is the only one.