Wolfram ResearchProductsPurchasingServices & ResourcesAbout UsOur Sites
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.

Documentation  / Mathematica / Built-in Functions  / Advanced Documentation / Linear Algebra / Matrix and Tensor Operations /

 

Import and Export of Matrices

This section reviews the functions that are available for importing and exporting matrices.

Mathematica provides a number of different tools for input/output. If you want to save your data in a file so that later you or a colleague can continue to work with it in Mathematica, you might want to use some of the functions that work with Mathematica expressions in files. These are discussed in the section Expression Input and Output.

If you want to work with matrices from a source external to Mathematica using specific data formats, the functions Import and Export are useful. The Import function supports a variety of different formats, some of which are relevant to matrices.

In[1]:=

Out[1]=

The Table format will read tabular data into Mathematica. This format is not specific to matrices and can process different types of information such as numbers, dates, and currencies. However, this is often a simple way to read in a matrix. This example displays a sample data file.

In[2]:=

Now the data file is read into Mathematica with the Import command using a format of Table; the result is a matrix.

In[3]:=

Out[3]=

Export can be used to write out a matrix in some particular format. Here it uses the Table format.

In[4]:=

Out[4]=

In[5]:=

This example shows how to write a matrix into a CSV format. This could be read into another application such as a spreadsheet.

In[6]:=

Out[6]=

In[7]:=

There are other matrix formats. For example, Harwell-Boeing, used for sparse matrices, and Matrix Market, used for both sparse and dense matrices. These are discussed in the section Import and Export of Sparse Matrices. In addition the MAT matrix format and the FITS astronomical data format can also be useful as import or export formats.



Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information


 © 2008 Wolfram Research, Inc.  Terms of Use  Privacy Policy |
Sign up for our newsletter: