"Cody" wrote in message <firstname.lastname@example.org>... > Thanks for the suggestions! I was able to pass the pointer created in the mex functions by a lower-level C library back to the Matlab environment in an appropriately sized mxArray and then back into a different mex function as suggested. I was also able to declare a persistent memory location in the mex-file C-code so that sucessive invocations of the same mex function could access the pointer.
I'm facing exactly the same problem: I have a USB device to which I can transmit data via a provided driver. I call the driver's functions within a mex-File and want to open the device, transmit data and eventually close the device. The handle which I receive from the open-function (of the driver) is an unsigned long variable. However, I'm quite frustrated because I'm not able to pass this device handle back to Matlab so as to call another mex-function which internally calls the driver function to transmit data. So far, I've tried to create a persistent variable using mxCalloc and mxMakeMemoryPersistant but this approach does not result in the desired functionality.
I would really appreciate it if you give me a hint or some code snippets explaining your solution of this issue.