Boolean matrix in mex file

조회 수: 5 (최근 30일)
Alessandro Masullo
Alessandro Masullo 2015년 2월 24일
댓글: Alessandro Masullo 2015년 2월 24일
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.

채택된 답변

Titus Edelhofer
Titus Edelhofer 2015년 2월 24일
Hi Alessandro,
use mxGetLogicals instead of mxGetPr ...
Titus
  댓글 수: 1
Alessandro Masullo
Alessandro Masullo 2015년 2월 24일
Thank you, I didn't know about that one.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Write C Functions Callable from MATLAB (MEX Files)에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by