matio-examples
matio-examples copied to clipboard
Make MyBoolVariable unsigned ?
I am actually not sure if the example for MyBoolVariable should use unsigned types (intead of signed) types. You might try it.
I tried it and it looks like it makes no difference to Matlab. As long as you set the MAT_F_LOGICAL flag Matlab (2015b) evaluate it as a bool, means: value = 0 -> false value != 0 -> true This behavior works with INT as parameter, too:
int intbool = 42;
matvar_t *variable = Mat_VarCreate(fieldname, MAT_C_INT16, MAT_T_INT16, 2, dim, &intbool, MAT_F_LOGICAL);
Evaluated as bool with value true in Matlab (Octave ignores the flag -> INT16 -> 42) When reading the value with matio you have to check the flag and then evaluate with the expression given above (value != 0)
Maybe it would be nice to add automatic convertion to matio.