Ubuntu Manpages

Mat_VarSetStructFieldByIndex

Sets a field in a structure array by index.

#include <matio.h>

matvar_t *
Mat_VarSetStructFieldByIndex(matvar_t *matvar, size_t field_index, size_t index, matvar_t *field);

The () function assigns field to the structure field at 0-relative field index field_index for the structure element at linear index in matvar. The function requires matvar to be a structure variable created by () or (). When a field is assigned successfully, the field variable name is updated to match the structure field name.

On success, the previous field stored at the requested structure element and field position is returned. If no previous field was set, or if matvar is not a valid structure variable, NULL is returned.

This example assigns a field in a structure array by index.

matvar_t *old_field;

old_field = Mat_VarSetStructFieldByIndex(matvar, 1, 0, field2);
if ( old_field != NULL )
    Mat_VarFree(old_field);

Mat_VarCreateStruct(3), Mat_VarCreateStruct2(3), Mat_VarAddStructField(3), Mat_VarSetStructFieldByName(3)