From: Vaclav Smidl on 5 May 2010 16:12 Hi all, I am facing similar problem to: http://www.mathworks.com/matlabcentral/newsreader/view_thread/245835 However, the solution mentioned there does not seem to work. I have a class: classdef my_pdf properties mu end methods function validate(p) disp('true'); end end end In matlab I get: >> x=my_pdf; >> isobject(x) ans =1 >>validate(x) true When I code the following mex: void mexFunction ( int n_output, mxArray *output[], int n_input, const mxArray *input[] ) { mxArray * m=(mxArray *)input[0]; printf("%d",mxIsObject(m)); mexCallMATLAB(1, &m, 0, 0, "validate"); } The answer of my_mex(my_pdf) is: 0??? Error using ==> my_mex Undefined function or variable 'validate'. I guess that the class is defined in different scope than the mex file. However, the m-file with class definition is on the path. I even tried to do save it in @my_pdf directory with no other effect. Running on 2008a and 2009a with the same results. Thanks for any hint. Vaclav
From: Philip Borghesani on 5 May 2010 17:25 You have two problems: > void mexFunction ( int n_output, mxArray *output[], int n_input, const mxArray *input[] ) { > mxArray * m=(mxArray *)input[0]; > printf("%d",mxIsObject(m)); > mexCallMATLAB(1, &m, 0, 0, "validate"); } Do not use mxIsObject it is now obsolete and only works for old stile objects. from matrix.h: /* * This function is deprecated and is preserved only for backward compatibility. * DO NOT USE if possible. * Is array user defined MATLAB v5 object */ EXTERN_C bool mxIsObject( const mxArray *pa /* pointer to array */ ); Your second problem is that you are passsing your input in as an output:int mexCallMATLAB(int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[], const char *functionName);You should be passing m in on the rhs:mexCallMATLAB(1, output, 1, &m, "validate"); /* will return output of validate to MATLAB */
From: Vaclav Smidl on 7 May 2010 08:51 Thank you very much. The second problem is solved, silly me. How about the mex counterpart of isobject? Is there any way to check that the input is an object, or even what class it is? "Philip Borghesani" <philip_borghesani(a)mathworks.spam> wrote in message <hrsnoi$prq$1(a)fred.mathworks.com>... > You have two problems: > > > void mexFunction ( int n_output, mxArray *output[], int n_input, const mxArray *input[] ) { > > mxArray * m=(mxArray *)input[0]; > > printf("%d",mxIsObject(m)); > > mexCallMATLAB(1, &m, 0, 0, "validate"); } > > > Do not use mxIsObject it is now obsolete and only works for old stile objects. from matrix.h: > /* > * This function is deprecated and is preserved only for backward compatibility. > * DO NOT USE if possible. > * Is array user defined MATLAB v5 object > */ > EXTERN_C bool mxIsObject( > const mxArray *pa /* pointer to array */ > ); > Your second problem is that you are passsing your input in as an output:int mexCallMATLAB(int nlhs, mxArray *plhs[], int nrhs, > mxArray *prhs[], const char *functionName);You should be passing m in on the rhs:mexCallMATLAB(1, output, 1, &m, "validate"); /* > will return output of validate to MATLAB */ >
|
Pages: 1 Prev: Extracting nested data into N dim array Next: VB6.0 interface with Matlab |