Much of the material below is from Chapters 1, 5, and 11 of the book Essential Mathcad ©2009, Elsevier Inc.

Note: For this worksheet, ORIGIN is set to 1

A vector is simply a matrix with only one column.

Use the Insert Matrix dialog box to create a matrix. This dialog box can be accessed in three ways: Selecting Matrix from the Insert menu; typing the shortcut CTRL+ M.; or selecting the matrix icon (showing a three by three matrix) on the Matrix toolbar. For a vector, the columns field in the dialog box should be set to 1.

Range variables have a beginning value, an incremental value, and an ending value. To define a range variable:

- Type the variable name followed by a colon;
- In the placeholder, type the beginning value followed by a comma.
- In the new placeholder type the incremental value followed by a semicolon. This inserts two dots and adds a third placeholder.
- Now enter the ending value.

Range variables are best used to increment expressions, iterate calculations, and to set plotting limits. When you use range variables to iterate a calculation, it is important to understand that Mathcad begins at the beginning value and iterates every value in the range. You cannot tell Mathcad to only use part of the range variable. If you use a range variable as an argument for a function, the result is another range variable, which means that the result is displayed, but you cannot access individual elements of the result. Also, you cannot assign the result to a variable.

Even though it is possible to use a range variable as an argument for a function, it is best to use a vector, so that each element of the result can be assigned and accessed.

It is important to understand the difference between a range variable and a vector.

The following two examples illustrate the benefits of using vectors rather than range variables when you need to assign and access the results of a function or equation.

This example compares the difference between using a range variable and a vector as input to a function.

Create range variable RV

Create user-defined function

The range variable may be used as the argument of the function. Units may also be added to the function argument. The range variables do not need to be integers when using them in a function.

The results are displayed, but you cannot access or reuse individual results.

Mathcad gives you an error if you try to assign this result to a variable.

In order to make each result accessible, you need to assign the results to a vector.

Create vector "v" similar to the range variable. Attach units of cm to the vector. Type CTRL+ M to start the vector.

The answers are the same as above, but by using a vector, each element of the result is now accessible.

Note: The above subscript is an array subscript typed by using the " [ " key. It is different from a literal subscript typed by using the " . " key. Array subscripts are used with vectors and matrices.

Use the range variable "RV" and the vector "v" from the previous example.

Type the expression π *RV2 to use the previously defined variable "RV." The results are displayed, but are not accessible, and the expression cannot be assigned to a variable.

Mathcad gives you an error if you try to assign this result to a variable.

Assign the variable CircleArea_1 to the expressions π *v2, where "v" is a previously defined vector variable.

Each element of the results is now accessible.

Mathcad does not have a simple way to create a vector with a range of values.

The following function creates a "range vector" similar to creating a range variable. It is from Figure 11.8 of the book Essential Mathcad.

This function creates a vector with a range of values. This is based on a function in the February 2002 Mathcad Advisor Newsletter.

The for loop creates a range variable for iterating from the three input arguments. The vector "Vec" is a local variable.

Create a variable with range from 0 to 1 with 0.1 increment.

These two variables appear to be identical, but they behave very differently.

If you would like to have the above function always available in your worksheets, add the function to your default template "Normal.xmct."

Much of the material above is from Chapters 1, 5, and 11 of the book Essential Mathcad ©2009, Elsevier Inc.