Defining Vectors and Matrices Using Data Elements

Once you have defined the sets of array labels that you wish to use, you can create vectors and matrices. The primary way to create vectors and matrices is to define them using Data elements. Once these exist, other vectors and matrices can be created by other kinds of elements based on these (e.g., by using these as inputs).

You specify that a Data element is to be a vector or a matrix when you define its output attributes (by pressing the Type… button in the element’s properties dialog).  The dialog for specifying output attributes for an element looks like this:

The Order drop-list provides three choices: “Scalar” (the default), “Vector (1D-Array)”, and Matrix (2D-Array)”.

If you wish to create a vector, select “Vector (1D-Array)”. If you wish to create a matrix, select “Matrix (2D-Array)”. If you select “Vector (1D-Array)”, the Row Labels field becomes available. If you select “Matrix (2D-Array)”, both the Row Labels and Column Labels fields become available. These two fields contain lists of all of the sets of array labels defined in your model:

If you have defined the Order as a vector or a matrix (i.e., if the Row Labels or Column Labels fields are active), you must select a set of array labels (or GoldSim will display a warning message when you try to close the Output Attributes dialog).

Note that within the drop-list for the Row and Column labels is the choice to “Create new Array Labels…”. If you click this option, the dialog for defining new array labels will be displayed. After leaving the Array Labels dialog, you will be returned to the dialog for defining output attributes.

To illustrate how you would create a vector or a matrix Data element, consider the following example. Suppose that you defined the Order as “Vector (1D-Array)”, and defined the Row Labels as “Days”. The properties dialog for the Data element would look like this.

Note that this dialog is different from the standard Data element dialog for a scalar.

In particular, because it is an array, you cannot directly edit the Data input field. To edit the vector, you must press Edit Data…, which will display the following dialog.

This dialog displays all items of the vector (in this case, seven). Each field is a standard edit field (you can enter a number, an expression or a link), although typically you would enter just a number (with units).

Note that the equivalent dialog for a matrix looks like this (in this example using a set of array labels for the Column Labels named Fruit with members Apples, Oranges, Peaches and Pears):

Although you would typically enter constants (numbers) into the input fields defining a vector or a matrix, the fields accept links and expressions. For example, you could create a vector of Stochastics by entering a link to a Stochastic for each item in a vector.

   Note: You can paste data from a spreadsheet, a Word table, or a tab-delimited text file directly into a vector or matrix grid. To do so, copy the data to the clipboard, select the cell in the vector or matrix representing the upper left-hand corner of the range into which you wish to paste (by single-clicking in it), and press Ctrl+V.

   Note: You can resize the columns of the editing dialog by dragging the lines separating columns right or left. You can also resize the entire dialog by dragging a side (or a corner).

Related Topics…

Learn more about: