MATLAB: How to call a C library function from MATLAB 7.2 (2006a), when the input is a structure that is defined in the DLL’s header file

libraryMATLABsharedshrlib

I would like to call a C library function (DLL) from MATLAB 7.2 (2006a), when the input is a structure that is defined in the DLL's header file.

Best Answer

The commands below illustrate how to use LIBSTRUCT in order to create a pointer to a structure defined in the DLL's header file. Once you have downloaded the attached files, you can execute the following commands at the MATLAB command prompt.
loadlibrary('test','test.h')
a.x = 0; a.y = 0; a.z = 0;
b = libstruct('length_3D',a)
calllib('test','testfunction',b)