comp

Syntax

f = comp(v,i1<,i2>)
comp(v,i1<,i2>) = f

Get/set the vector/tensor component.

For vectors, the optional i2 cannot be given, and i1 refers to the vector component from 1 to the size of the vector (i.e., 1 to 2 for a 2D vector, 1 to 3 for a 3D vector).

For matrices, the i1 and i2 values correspond with the row/column position.

For tensors, if i1 is given alone, then this is an integer from 1 to 6 accessing the \(xx\), \(yy\), \(zz\), \(xy\), \(xz\), and \(yz\) components (in that order). If the optional i2 is given, then these values are used as row/column indices in the tensor (i.e., i1 = 2 and i2 = 3 retrieves the \(yz\) component).

Returns:

f - vector or tensor value

Accepts:

f - vector or tensor value

Arguments:

v - vector, matrix pointer, or tensor pointer

i1 - vector, matrix, or tensor component. For vectors, the admissible values are {1 or 2 for 2D vectors; 1, 2, or 3 for 3D vectors}. For matrices, this is the row position and must be given with i2 for multidimensional matrices. For tensors, in the absence of i2, the following values are admissible:

  • 1 \(xx\) component
  • 2 \(yy\) component
  • 3 \(zz\) component
  • 4 \(xy\) component
  • 5 \(xz\) component
  • 6 \(zz\) component

i2 - Optional matrix/tensor component that is used as the column index.