Why do I get a runtime error when I use the NEQ function in the MATLAB C++ Math Library?

2 views (last 30 days)
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.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
This is a bug in the MATLAB C++ Math Library. This has been brought to the attention of our development staff to be addressed in a future version of the C++ Math Library.
As a workaround, please use the "!=" operator for not equals instead of the functional form.

More Answers (0)

Categories

Find more on C Shared Library Integration 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!