Boolean matrix in mex file

15 views (last 30 days)
Hello everyone,
I'm trying to read a logical matrix in a mex file with matlab. The way I usally do for reading matrices in matlab is:
double *var = mxGetPr(prhs[0]);
If the variable in matlab is logic, I get weird results in C++, but if I try to initialize var as boolean:
bool *var = mxGetPr(prhs[0]);
I get:
error C2440: 'initializing' : cannot convert from 'double *' to 'bool *'
The only solution I've found, for the moment, is passing the logical matrix as double to the mex routine, but I'd prefer reading the boolean matrix instead.
How can I do that?
Alessandro.

Accepted Answer

Titus Edelhofer
Titus Edelhofer on 24 Feb 2015
Hi Alessandro,
use mxGetLogicals instead of mxGetPr ...
Titus
  1 Comment
Alessandro Masullo
Alessandro Masullo on 24 Feb 2015
Thank you, I didn't know about that one.

Sign in to comment.

More Answers (0)

Categories

Find more on Operators and Elementary Operations in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!