Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make MyBoolVariable unsigned ? #2

Open
tbeu opened this issue Jan 6, 2016 · 1 comment
Open

Make MyBoolVariable unsigned ? #2

tbeu opened this issue Jan 6, 2016 · 1 comment
Assignees

Comments

@tbeu
Copy link
Contributor

tbeu commented Jan 6, 2016

I am actually not sure if the example for MyBoolVariable should use unsigned types (intead of signed) types. You might try it.

@NJannasch NJannasch self-assigned this Jan 7, 2016
@NJannasch
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants