Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

A simple question about the getting results using Matlab engine.

1 visualización (últimos 30 días)
Gil
Gil el 7 de Mzo. de 2013
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
Hi,
I am trying the following simple code to compute the sum of two numbers:
double *x;
mxArray *m_X;
m_X=mxCreateDoubleMatrix(1,1,mxREAL);
x=new double();
*x=3;
memcpy((void *)mxGetPr(m_X),(void *)x,sizeof(double)*1);
engPutVariable(ep,"x",m_X);
double *s;
mxArray *m_S;
m_S=mxCreateDoubleMatrix(1,1,mxREAL);
s=new double();
*s=3;
memcpy((void *)mxGetPr(m_S),(void *)s,sizeof(double)*1);
engPutVariable(ep,"s",m_S);
engEvalString(ep,"s=sum2(x,x)");
double *cresult;
mxArray *mresult;
mresult=engGetVariable(ep,"s");
cresult=new double();
cresult=mxGetPr(mresult);
Notice I create another variable "s" and inject it into Matlab to store the results. Next, I try to call the function sum2 and store the results in "s" and then I try to get the value of "s" from Matlab. I expect the value of "s" to be 6, but it stays 3, the value it was initialized with.
What am I doing wrong? How can I get the result of calling the function "sum2" from Matlab?
Thank you,
Gil.

Respuestas (0)

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by