MTX (.mtx)
MTX (.mtx)
Background & Context

-
- Matrix Market matrix format.
- Used for exchanging and storing test matrices.
- Plain text format.
- File format of the NIST Matrix Market collection of standard test matrices.
- Stores numerical or pattern matrices in a dense ("array format") or sparse ("coordinate format") representation.
- Developed in 1996 by R. Boisvert, R. Pozo, K. Remington, and J. Dongarra.
- Maintained by the US National Institute of Standards and Technology (NIST).
Import & Export

- Import["file.mtx"] imports matrix data from a Matrix Market file.
- The Wolfram Language converts "array format" files to packed arrays and "coordinate format" files to sparse arrays.
- Import["file.mtx",elem] imports the specified element.
- The import format can be specified with Import["file","MTX"] or Import["file",{"MTX",elem,…}].
- Export["file.mtx",expr] exports any numerical or pattern matrix to a Matrix Market file.
- Export["file.mtx",expr,elem] creates a Matrix Market file by treating expr as specifying element elem.
- See the following reference pages for full general information:
-
Import, Export import from or export to a file CloudImport, CloudExport import from or export to a cloud object ImportString, ExportString import from or export to a string ImportByteArray, ExportByteArray import from or export to a byte array
Import Elements

- General Import elements:
-
"Elements" list of elements and options available in this file "Summary" summary of the file "Rules" list of rules for all available elements - Data representation elements:
-
"Data" matrix data given as a packed or sparse array "Graphics" a visual representation of the values of the matrix elements - Import uses the "Data" element by default.
- Import["file.mtx","Graphics"] uses MatrixPlot to render the matrix structure as graphics.
- Data descriptor elements:
-
"DataFormat" matrix data type "Dimensions" matrix dimensions - Metainformation elements:
-
"Comments" user comments stored in the file "MatrixStructure" symmetry properties of the matrix - Possible values for "MatrixStructure" are:
-
"Hermitian" matrix that is equal to its own conjugate transpose "General" matrix without transposition symmetry "SkewSymmetric" matrix whose transpose is also its negative "Symmetric" matrix that is equal to its transpose
Examples
open all close allBasic Examples (2)
Scope (3)
Import (2)
Export (1)
Export a NumericArray to MTX:
Import Elements (7)
Export Options (5)
"Comments" (3)
"MatrixStructure" (2)
By default, Export automatically determines the symmetry of the matrix:
Use the "MatrixStructure" option to overwrite the default behavior:
See Also
History
Introduced in 2007 (6.0) | Updated in 2025 (14.3)