c - How to access class value in a Matlab mex file? -


this simple dummy class using .m file in matlab.

function obj = dummy(varargin)   if nargin~=1     error('nothing here')     return   end    obj = init_fields;   obj = class(obj, 'dummy');   obj.file = varargin{1};  end  function obj = init_fields()   obj.file = []; end  >> = dummy('file.name'); 

i can access a.file in other .m function-files. e.g. something = newfunction(a)

but how can access value of obj.file in c written mex function (that can fopen("file.name"))?

mxarray *pa; mexprintf("%s\n", mxgetfieldnamebynumber(prhs[0], 0)); pa = mxgetfieldbynumber(prhs[0], 0, 0); mexprintf("%s\n", pa); /* don't work */ mexcallmatlab(0, null, 1, &pa, "disp"); /* works * / 

any ideas?

as of r2014a, there 2 api functions in matlab matrix library: mxgetproperty , mxsetproperty. (see this) long object simple value class public properties, should work. otherwise have use mexcallmatlab access data.


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -