Drive thorlabs Motorized Microscope Focus Controller with matlab
Mostrar comentarios más antiguos
Hi All
I am working on control Thorlabs focus drive MFC1 with Matlab. Thorlabs only offers its command function in header file ( ZStepper_SDK.h) in C++ and library ( ThorZStepper.dll; ThorZStepper.lib). They don't provide the source code. I am thinking about loading the library in Matlab with function "loadlibrary". It works for examples in mathworks. However, when I tried it with Thorlabs file
loadlibrary('ThorZStepper.dll','ZStepper_SDK.h')
, error came out:


Does anyone know how to fix the problem or any other way to control the focus drive with Matlab. I appreciate it a lot.
Respuestas (1)
Walter Roberson
el 12 de Oct. de 2018
Editada: Walter Roberson
el 12 de Oct. de 2018
0 votos
In C, & is the unary operator used to take the address of something, or is the bitwise "and" operator. Either way, it is an operator, and cannot appear in a type declaration -- only in an executable expression (such as to initialize a variable.)
In C++, & can also be used in type declarations https://en.cppreference.com/w/cpp/language/declarations to indicate lvalues . This is the first time I have seen that described so I do not presently understand quite what the difference is compared to some of the other forms.
The code you are compiling uses & in type declarations. That means that the code is illegal as standard C -- although possibly valid under some extension.
MATLAB's loadlibrary() can only work with C language .h files, not with C++ header files. (The .h file could potentially be dual-purpose, as long as it protected the C++ specific portions with a #if or #ifdef )
Starting in R2018a, a new C++ MEX API was added to make it easier to call MATLAB from within C++. However, that interface does not provide any added support for calling third-party C++ from within MATLAB.
Comunidades de usuarios
Más respuestas en Power Electronics Control
Categorías
Más información sobre Write C Functions Callable from MATLAB (MEX Files) en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!