Ubuntu Manpages

Mat_VarSetStructFieldByName

Sets a field in a structure array.

#include <matio.h>

matvar_t *
Mat_VarSetStructFieldByName(matvar_t *matvar, const char *field_name, size_t index, matvar_t *field);

The () function assigns field to the structure field named field_name 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 fields in a structure array by name and by index.

matvar_t *old_field;

old_field = Mat_VarSetStructFieldByName(matvar, "field1", 0, field1);
if ( old_field != NULL )
    Mat_VarFree(old_field);

Mat_VarCreateStruct(3), Mat_VarCreateStruct2(3), Mat_VarAddStructField(3), Mat_VarSetStructFieldByIndex(3)