passing value from mex file to Matlab
1 次查看(过去 30 天)
显示 更早的评论
Am writing a multi threaded program in Matalb..Hence am taking the support of Mex to do...Am having some set of variable in the mex space..which I want to return it back to the Matlab workspace..Please somebody tell how to do it..
2 个评论
Jan
2013-6-25
The question is too vague to be answered. In my MEX programs the results are collected in one array and replied as Matlab-array. But I do not think, that this is helpful already.
采纳的回答
Friedrich
2013-6-25
编辑:Friedrich
2013-6-25
Hi,
#include "mex.h"
void manipulate(double* y){
*y = 20;
}
void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
plhs[0] = mxCreateDoubleScalar(10);
//uncomment this get the the value 20 in MATLAB, otherwise you get 10
//manipulate(mxGetPr(plhs[0]));
}
Overall i think the best is to get started in the MEX documentation or here or take a look at some examples.
0 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!