passing value from mex file to Matlab

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
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.
sandeep
sandeep 2013년 6월 25일
편집: sandeep 2013년 6월 25일
sorry its like am having a function in a cpp program like
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray
*prhs[])
{
double y=10;
}
I want to do some more manipulation on the value y in this function and return it to Matlab workspace...To do this I executed mex which created mexw64 file...Upton execution of this file I want to value y to be available to matlab workspace...Is it possible?

댓글을 달려면 로그인하십시오.

 채택된 답변

Friedrich
Friedrich 2013년 6월 25일
편집: Friedrich 2013년 6월 25일

0 개 추천

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개)

카테고리

도움말 센터File Exchange에서 Write C Functions Callable from MATLAB (MEX Files)에 대해 자세히 알아보기

태그

질문:

2013년 6월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by