Nested Arrays |
An array element does not need to be only a scalar or single number. An array element can be another array, so that you have an array within an array or a nested array. Nested arrays behave very much like arrays whose elements are all scalars. However, there are some distinctions, as described below.
![]() |
Defining a Nested Array |
You define a nested array in much the same way you would define any array. The only difference is that you cannot use the Matrix command from the Insert menu with a selected placeholder in an existing array. You must click on a placeholder in an array and type the name of another array. You can display nested matrices inside matrices.
The simplest way to define an array element that is itself an array is to assign the element using the subscript operator, for example
M[1,1 := v
The element in row and column 1 of M is now the vector v.
Additional methods include using a file access function such as READPRN in the array of placeholders created using the Insert Matrix command, and using the programming operators in Mathcad to build up an array whose elements are themselves arrays.
The display of a nested array is controlled by Display Styles settings in the Result Format dialog. You can expand a nested array when the array is displayed in matrix form. When an array element is itself an array, you see bracket notation showing the number of rows and columns rather than the array itself. If the nested array is displayed as an output table, you can expand it to see the underlying array. Click on the array element, then right-click and choose Down One Level from the menu. Choose Up One Level from the menu to restore the array element to non-expanded form.