mxGetPr inside mexFunction returning null

i have a mexFunction() which i compile under visual studio.
inside the mexFunction() i have sometthing like
double *a = mxGetPr(nrhs[1]);
the complilation is fine and in the debug mode i am able to enter the mexFunction and stop at the "double *a" line but i get null for "a".
i am unable to figure out what the problem may be. For a different program similar procedures work.

Respuestas (1)

Jan
Jan el 20 de Jul. de 2013
Editada: Jan el 21 de Jul. de 2013

0 votos

"I have something like" is not sufficient for a question. Obviously there is a problem with the specific code, therefore posting something similar cannot help to find the bug.
mxGetPr(prhs[1]) works correctly, whenever the function was called with at least 2 inputs and the 2nd one is a double array. Is this the case?
[EDITED] James saw, that "nrhs" is wrong here and "prhs" must be meant.

3 comentarios

Kaushik
Kaushik el 21 de Jul. de 2013
mxGetPr(nrhs[1]) was the only thing that was inside the mexFunction(). I was trying to see whether the pointer is read correctly. I found that mxGetPr(nrhs[1]) is not working if i have "#include mclmcrrt.h". When I comment out the mclmcrrt.h header mxGetPr(nrhs[1]) starts returning non-null pointers.
James Tursa
James Tursa el 21 de Jul. de 2013
I am assuming that nrhs[1] is a typo and should be prhs[1] ... true? And as Jan has already said, please post your code instead of making us guess with your code snippets. Also post how you are calling the function from the m-file level.
Jan
Jan el 21 de Jul. de 2013
@James: Oh. I've overseen the obviously confused "nrhs" and "prhs". It was almost midnight and one of the hottest nights we can have in central Europe.

Iniciar sesión para comentar.

Categorías

Etiquetas

Preguntada:

el 20 de Jul. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by