Using the C Math Library | ![]() ![]() |
Assigning Values to a Structure Field
To assign an initial value to a field (creating the field if it doesn't exist) or modify the value of an existing field, use mlfIndexAssign()
. For example, to change the description field of the seventeenth image, you'd write this code:
mlfIndexAssign(&images, "(?).description", mlfScalar(17), mxCreateString("Cloned sheep embryo #1"));
Note that you must pass the array being modified to mlfIndexAssign()
as an mxArray **
, rather than the mxArray *
that mlfIndexRef()
requires.
images(17).description = 'Cloned sheep embryo #1'
performs the same operation in MATLAB.
![]() | Accessing the Contents of a Structure Field | Assigning Values to Elements in a Field | ![]() |