フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

A simple question about the getting results using Matlab engine.

1 回表示 (過去 30 日間)
Gil
Gil 2013 年 3 月 7 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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.
  1 件のコメント
Gil
Gil 2013 年 3 月 7 日
never mind. I solved it.

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by