How to | Input a Matrix

The Wolfram Language supports operations on matrices of any size and has a range of input methods appropriate for different needs, from small, formatted matrices via keyboard or palettes to text-based entry or automatic import.

This page requires that JavaScript be enabled in your browser.
Learn how »

Selected examples from the video:

Lists are very important general structures in the Wolfram Language. A matrix in the Wolfram Language is represented as a list of sublists of the same length.

Input a matrix:

In[4]:=
Click for copyable input
Out[4]=

Use MatrixForm to display as a matrix:

In[5]:=
Click for copyable input
Out[5]//MatrixForm=

The Wolfram System also has a user interface to input matrices.

Select Insert Table/Matrix New:

In the window that appears, select Matrix (List of lists), enter the number of rows and columns for your matrix, and click OK:

Your matrix is inserted into your notebook:

Click for copyable input

Click a placeholder to enter input. Once one is highlighted, you can move to the next one using the tab or arrow keys:

Evaluating the matrix gives its underlying structure as a uniform nested list:

In[6]:=
Click for copyable input
Out[6]=

You can also enter matrices using the Basic Math Assistant palette.

Open the palette from the Palettes menu:

On the Advanced tab, click the Matrix button to insert a 2×2 matrix:

As before, you can move through the empty placeholders using the tab or arrow keys.

To create a new row, use Ctrl+ Enter. The new row will be inserted immediately below the position of your cursor. Pressing Ctrl+ Enter with the cursor positioned after any entry in the last row creates a new row at the bottom of the matrix:

Similarly, new columns can be entered using Ctrl+ ,:

    

You can import a matrix from a file. In this example, data is imported from a file and displayed in MatrixForm:

In[1]:=
Click for copyable input
Out[1]//MatrixForm=