Different Ways to Initialize an Array in Mathcad
Before an array can be used, it must be filled with values, or initialized. There are several ways to initialize an array in Mathcad:
1.
You can type the values from the keyboard. Select Insert / Matrix to do that.
2.
You can read the values from a file. Depending on the version of Mathcad you use, select either Insert / Data / File Input, or select Insert / Component / File Read or Write to do that. The File Read component allows you to establish a connection to a data file, read data from it, and assign the data to a Mathcad variable (a matrix or a vector name).

The File Read component reads the file each time the Mathcad worksheet is calculated (using Tools / Calculate / Calculate Worksheet), so changes to the values in the file are reflected in the worksheet.
3.
You can use an input table to fill the array. Depending on the version of Mathcad you use, select either Insert / Data / Table, or Insert / Component / Input Table to do that. You can either type the values into the table, or you can right-click on the table and select Import from the pop-up menu.

When you import values (for example from an Excel worksheet) into an input table, the file is read once, and the values are copied into the Mathcad worksheet. Changes to values in the file are not reflected in the worksheet.
4.
You can create an array by computing its elements by using range variables.
5.
You can compute the array element values by using the matrix() function. Mathcad matrix() function allows you to fill an array with computed values without explicitly declaring range variables.

matrix(m,n,f) creates a matrix in which the i-jth element contains f(i,j),
where:
i = 0,1..m-1 and j = 0,1.. n-1
m is the number of rows the matrix will have.
n is the number of columns the matrix will have.
f is a function of two variables.
6.
You can create an array by copying and pasting an array from another window program. For example you can copy two columns from an Excel spreadsheet to the Windows clipboard (Edit/Copy), then begin an array definition in Mathcad:
then click on the placeholder, and paste the contents of the clipboard into the placeholder using Mathcad Edit/Paste.
^ Top