Why do I get a runtime error when I use the NEQ function in the MATLAB C++ Math Library?
The following code, "example.cpp", reproduces this problem:
#include "matlab.hpp"#include <stdlib.h> /* used for EXIT_SUCCESS */static double xdata[] = { 1,2,3,4,5,6,7,8 };int main(int argc, char* argv[]){ mwArray temp1(2,4,xdata); mwArray temp2(2,4,xdata); mwArray z = zeros(2,4);;// z = eq(temp1,temp2); // this works ok z = neq(temp1,temp2); // this is BROKEN// z = temp1 != temp2; // this works ok// z = temp1 == temp2; // this works ok cout <<"z: "<<z << endl; return 0;}
To compile and run this in MATLAB, I used the following command:
mbuild example.cpp!example
With the code above, I would get a runtime error. However if I uncomment any other line and comment the line using NEQ, i.e.
z = eq(temp1,temp2); // this works ok // z = neq(temp1,temp2); // this is BROKEN// z = temp1 != temp2; // this works ok// z = temp1 == temp2; // this works ok
The program executes correcty.
Best Answer