Prev: how can i get minimum positive value in an expression number of solutions, give me the code for this
Next: OFDM transmission into multipath channel
From: Etienne on 31 Jan 2010 13:25 Hi Folks Are there any examples of setting object properties via the mxSetProperty function. I would like to send an object into a fortran mex function, do some calculations on certain properties, update the object and send it back out. Usually thye functions have examples that go with them, but these functions do not seem to have any. Any help would be appreciated. Etienne
From: James Tursa on 1 Feb 2010 11:06 "Etienne" <etienne.coetzee(a)airbus.com> wrote in message <hk4hu4$or9$1(a)fred.mathworks.com>... > Hi Folks > > Are there any examples of setting object properties via the mxSetProperty function. I would like to send an object into a fortran mex function, do some calculations on certain properties, update the object and send it back out. Usually thye functions have examples that go with them, but these functions do not seem to have any. > > Any help would be appreciated. > > Etienne Be aware that mxGetProperty and mxSetProperty apply to the "new" object method in MATLAB, not the old struct-style object method. The old method would use the struct API functions to get and set "properties". There are issues with doing what you propose. First, if you restrict yourself to the regular API functions, then you will have to make a deep copy of the object before changing one of its properties. This may or may not be an issue depending on how large the object is. If it is large, then doing this at the MATLAB level and not at the mex level will allow MATLAB to naturally use shared data copies when appropriate, and I would guess it could be much more efficient. I suppose you could use the undocumented mxCreateSharedDataCopy to get some of this efficiency in a mex routine, but I have never attempted it on a new style object. As far as actually using mxGetProperty and mxSetProperty, the doc seems pretty clear on the use. mxGetProperty gets a *copy* of the property as a separate mxArray variable, and mxSetProperty makes a *copy* of the mxArray property to use in the object. So just work with the properties as regular mxArray variables using all of the other API functions. James Tursa
From: James Tursa on 1 Feb 2010 18:03 "James Tursa" <aclassyguy_with_a_k_not_a_c(a)hotmail.com> wrote in message <hk6u5d$ooe$1(a)fred.mathworks.com>... > ... I suppose you could use the undocumented mxCreateSharedDataCopy to get some of this efficiency in a mex routine, but I have never attempted it on a new style object. And another complication is that I don't even know how to use mxCreateSharedDataCopy in a Fortran mex routine. My attempts to use a similar interface as its C counterpart never worked. Couldn't get it to find the routine and link. James Tursa
From: Etienne on 2 Feb 2010 13:41 Thanks James I have spent the whole day going through mex fortran exercises, and have a better idea of how the mex functions work. I am not a Fortran guru, but am having to hack somebody else's fortran code. I now want to use an object to set some simulation parameters for the fortran program. The fortran program then goes away, runs, and I want to write the final results back to the object. I thought I had it worked out, but I am still getting a problem when I use the mxGetPropery and mxSetProperty. I'll keep on trying. Cheers Etienne
From: Etienne on 2 Feb 2010 17:15
Thanks James I have spent the whole day going through mex fortran exercises, and have a better idea of how the mex functions work. I am not a Fortran guru, but am having to hack somebody else's fortran code. I now want to use an object to set some simulation parameters for the fortran program. The fortran program then goes away, runs, and I want to write the final results back to the object. I thought I had it worked out, but I am still getting a problem when I use the mxGetPropery and mxSetProperty. I'll keep on trying. Cheers Etienne |