Wolfram ResearchPRODUCTSPURCHASEFOR USERSCOMPANYOUR SITES
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.

Extending Matrices

You can increase the size of a matrix by padding it with PadLeft and PadRight.

In[1]:= 

Out[2]//MatrixForm=

PadLeft adds the elements to the beginning of the matrix. This example returns a 4Cross4 sparse matrix.

In[3]:= 

Out[3]=

You can see the result with MatrixForm.

In[4]:= 

Out[4]//MatrixForm=

PadRight adds the elements to the end of the matrix; the result is a sparse array.

In[5]:= 

Out[5]//MatrixForm=

You can use PadLeft to pad on the right if you specify negative indices.

In[6]:= 

Out[6]//MatrixForm=

One important use of the padding functions is to replicate and tile a matrix. In this example the input matrix is extended to have two versions in every row and three in every column.

In[7]:= 

Out[8]//MatrixForm=

In[9]:= 

Out[9]//MatrixForm=

PadLeft and PadRight have a number of extra features. These are described in the Mathematica documentation.


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



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