S = spconvert(D)
load and save commands handle sparse matrices, so there is no need for a special sparse load or save command. However, conversion between the external form and internal form of a sparse matrix is needed after loading from an ASCII text file.
S = spconvert(D) converts a matrix D with rows containing [i,j,s] or [i,j,r,s]to the corresponding sparse matrix. D must have an nnz or nnz+1 row and three or four columns. Three elements per row generate a real matrix and four elements per row generate a complex matrix. A row of the form [m n 0] or [m n 0 0] anywhere in D can be used to specify size(S). If D is already sparse, no conversion is done, so spconvert can be used after D is loaded from either a MAT-file or an ASCII file.
uphill.dat contains
Then the statements1 1 1.0000000000000001 2 0.5000000000000002 2 0.3333333333333331 3 0.3333333333333332 3 0.2500000000000003 3 0.2000000000000001 4 0.2500000000000002 4 0.2000000000000003 4 0.1666666666666674 4 0.1428571428571434 4 0.000000000000000
recreateload uphill.datH = spconvert(uphill)
sparse(triu(hilb(4))), possibly with roundoff errors. In this case, the last line of the input file is not necessary because the earlier lines already specify that the matrix is at least 4-by-4.(c) Copyright 1994 by The MathWorks, Inc.