| Using the C Math Library | ![]() |
Assigning to a Subarray
Use two vector indices to generate a matrix destination. For example, let the vector index B = [1 2], and the vector index C = [2 3]. Then,
mlfAssign(&source, mlfVertcat(mlfHorzcat(mlfScalar(1), mlfScalar(4), NULL), mlfHorzcat(mlfScalar(3), mlfScalar(2), NULL), NULL)); mlfIndexAssign(&A, "(?,?)", B, C, source);
copies a 2-by-2 matrix into the second and third columns of rows 1 and 2: the upper right corner of A. The example matrix A becomes:
1 1 4 2 3 2 3 6 9
You can also use a logical matrix as an index. For example, let B be the logical matrix:
0 1 1 0 1 1 0 0 0
mlfIndexAssign(&A, "(?)", B, source);
1 1 4 2 3 2 3 6 9
| Assigning to Multiple Elements | Assigning to All Elements | ![]() |