<< mminfo MatrixMarket mmwrite >>

MatrixMarket >> MatrixMarket > mmread

mmread

Reads a Matrix Market file

Calling Sequence

A = mmread(filename)
[A,rows] = mmread(filename)
[A,rows,cols] = mmread(filename)
[A,rows,cols,entries] = mmread(filename)
[A,rows,cols,entries,rep] = mmread(filename)
[A,rows,cols,entries,rep,field] = mmread(filename)
[A,rows,cols,entries,rep,field,symm] = mmread(filename)
[A,rows,cols,entries,rep,field,symm,comments] = mmread(filename)

Parameters

filename

a 1-by-1 matrix of strings, path of the Matrix Market file.

A

a matrix of type 1 (real or complex matrix), 4 (boolean matrix), 5 (sparse matrix) or 6 (sparse boolean matrix).

rows

a 1-by-1 real matrix, number of matrix rows

cols

a 1-by-1 real matrix, number of matrix columns

entries

a 1-by-1 real matrix, number of nonzeros entries in the matrix

rep

a 1-by-1 matrix of strings, with values "coordinate" or "array"

field

a 1-by-1 matrix of strings, with values "real", "complex" or "pattern"

symm

a 1-by-1 matrix of strings, with values "general", "symmetric", "skew-symmetric", "hermitian"

comments

a 1-by-n matrix of strings, contains the comments present in the file header.

Description

Reads the contents of the Matrix Market file filename into the matrix A. A will be either sparse or full, depending on the Matrix Market format indicated by rep 'coordinate' (coordinate sparse storage), or 'array' (dense array storage). The data will be duplicated as appropriate if symmetry is indicated in the header.

Optionally, size information about the matrix can be obtained by using the return values rows, cols, and entries, where entries is the number of nonzero entries in the final matrix. Type information can also be retrieved using the optional return values rep (representation), field, and symm (symmetry).

Examples

filename = fullfile(mmgetpath(),"tests","unit_tests","A.mtx");
A1=mmread(filename)
A2=sparse([1,1;1,3;2,2;3,1;3,3;3,4;4,3;4,4],..
    [9;27+%i;16;27-%i;145;88;88;121],[4,4])

In the following example, we use all the output arguments of the mmread function.

filename = fullfile(mmgetpath(),"tests","unit_tests","A.mtx");
[A,rows,cols,entries,rep,field,symm,comments]=mmread(filename)

In the following example, we analyze a sparse file downloaded from http://math.nist.gov/MatrixMarket.

path = fullfile(mmgetpath (  ),"tests","unit_tests");
filename=fullfile(path,"ash331.mtx");
A = mmread(filename);
PlotSparse(A);

See Also

Authors

Copyright (C) 2009 - INRIA - Serge Steer

Copyright (C) 2011 - Benoit Goepfert

Copyright (C) 2011 - DIGITEO - Michael Baudin

Bibliography

http://math.nist.gov/MatrixMarket/formats.html

http://math.nist.gov/MatrixMarket/mmio/matlab/mmread.m


Report an issue
<< mminfo MatrixMarket mmwrite >>