MATLAB: Do I receive the warning message “mxGetPr should no longer be used with logical data type” when creating MEX function

arraylogical?MATLABmxgetdatamxgetprr12r13

mxGetPr should no longer be used with logical data type

Best Answer

This error occurs only if you pass a logical array as an input to your C-MEX function and use MXGETPR to extract the data from the same.
Logical datatypes were represented as double data until MATLAB 6.1 (Release 12.1). Starting with MATLAB 6.5 (R13), logical data type is a separate class. Since MXGETPR can only be used with double data type, you get the above-mentioned error.
As a solution, you can either convert the data to double using the DOUBLE function before passing it to your C-MEX function or use mxGetLogicals in your C-code.