Print Friendly and PDF

Working With Arrays

Jason -

This webinar was presented by Jason Lillywhite in August 2014. Below is a brief summary and video recording of the presentation. You can also download materials used during the presentation by clicking on the link(s) at the end of the article.

In this webinar, we explored using arrays in GoldSim. In many systems, it is beneficial to create and manipulate elements that represent collections of data rather than individual items. In GoldSim, vectors and matrices are used for collections of data, and vectors and matrices are each a type of array. Examples of collections of items or values include the number of individuals in a population by age and the average stream flow for each month of the year. In GoldSim, arrays are defined relative to a particular set of array labels. The labels are used to reference the items in the array and to display the items in the array. A vector is an array with only one value column, and a matrix is an array with more than one value column. With an array, a large number of elements, each representing an individual item or value, can be replaced with one element which represents the entire collection of items or values.

Arrays are useful in any model which deals with a collection of items or values. In addition to providing a data storage format for collections, arrays can also be manipulated in equations and used in/with built-in functions. Using a series of example elements and simple yet realistic models, we will walk through the nuances of using arrays in GoldSim starting at the fundamental level to help you learn to implement arrays in your own projects. The array-related topics will include:

  • Basic array creation including index set and index label creation;
  • Basic array manipulation and mathematical operations;
  • Vector and matrix functions that are built into GoldSim like vinterp() and vindex();
  • Using script elements to loop over arrays;
  • Accessing array items or values by index; and
  • Vector and matrix constructors.


The material presented in this webinar is useful for all systems modeling applications which benefit from the ability to represent a collection of items or values by a single element rather than with many elements.

Download the video and model file used during the presentation:

Webinar video recording


Here is a listing of built in vector functions in GoldSim:

Function Command
Constructor vector( , )
Item access  getitem(v, r)
Row access  getrow(v, r)
Length  getrowcount(v)
Sum  sumv(v)
Product  prodv(v)
Mean  meanv(v)
Standard deviation  sdv(v)
Minimum  minv(v)
Maximum  maxv(v)
Sort ascending  sort123(v)
Sort descending sort321(v)
Minimum ordinal rowmin(v)
Maximum ordinal rowmax(v)
Dot product dot(v, v)
Vector multiplication vvmatrix(v, v)



Here is a list of built-in matrix functions:

Function Command
Constructor  matrix( , )
Item access  getitem(m, r, c)
Row access  getrow(m, r)
Column access  getcolumn(m, c)
Length  getrowcount(m)
Width getcolumncount(m)
Sum items each row sumr(m)
Product items each row prodr(m)
Mean items each row meanr(m)
Standard deviation (e.r.) sdv(m)
Minimum each row minv(m)
Maximum  each row maxv(m)
Sum items each column sumc(m)
Product items each column prodc(m)
Mean items each column meanc(m)
Standard deviation (e.c.) sdc(m)
Minimum each column minc(m)
Maximum  each column maxc(m)
Matrix transpose trans(m)
Matrix inverse inv(m)
Minimum (term-by-term) min(m, m)
Maximum (term-by-term) max(m, m)
Dot product dot(v, v)
Matrix multiplication mult(m, m)



  • arrays
  • matrix
  • vector
Have more questions? Submit a request