# How to | Input a Matrix

*Mathematica* 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.

Selected examples from the video:

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

In[4]:= |

Out[4]= |

Use MatrixForm to display as a matrix:

In[5]:= |

Out[5]//MatrixForm= | |

*Mathematica* 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 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]:= |

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[7]:= |

Out[7]//MatrixForm= | |