Arrays and user-defined functions MathCad Help

The arguments in a function definition need not be scalar variables. They can also be vectors or matrices. Functions can return values that are scalars, vectors, or matrices.

Figure 10-21 shows some examples of functions with vector and matrix arguments and results

User functions used with vectors and matrices.

User functions used with vectors and matrices.

Note that if a function expects a vector or a matrix for an argument, it will not work on a scalar argument. In the example in Figure 10-21, trying to evaluate extent(3) will flag the equation with the an error message indicating that the argument must be an array.

If a function returns a vector or matrix as a result, you use the subscript and superscript operators to extract specific numbers. For example, in Figure 10-21, you could evaluate:

Arrays and user-defined functions

Arrays and user-defined functions

 

Posted on November 20, 2015 in Vectors and Matrices

Share the Story

Back to Top
Share This