I have a C++ code that I try to embed in Matlab using a mex function. Everything worked just fine, till I tried to hand over integers from Matlab.
Suppose I call my Mex function like:
myMexFun(0.1, 0.1, 30, 4000);
Apparently it makes a difference if I use: (1)
int a = (int)*mxGetPr(prhs);
instead of defining it directly in my C++ code with: (2)
Since the first (1) expression will yield very far off wrong results.
a is used for all calculating operations (+,-,*,/) as well as an index for arrays.
Additionally I am doing the very same thing with a smaller integer for another parameter prhs - (range 5-150) and with this input I do not get any issues.
What am I overseeing here?
Kind regards, and thanks for your time.