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:

Click for copyable input

Use MatrixForm to display m as a matrix:

Click for copyable input

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:

Click for copyable input

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 . The new row will be inserted immediately below the position of your cursor. Pressing 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 :


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

Click for copyable input


See Also

List  MatrixForm  Import