Problem using array in MATLAB with external library from DLL
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am using MATLAB to control Thorlabs software. I am having trouble with any of the functions from the imported library that need to return arrays. Here is an example of my code I am using and the description from the manual: my code:
waveType=libpointer('int32Ptr',0)
pupil=libpointer('int32Ptr',1)
arraywavefront=zeros(spotsy.value,spotsx.value,'uint16');
calllib('WFS_64','WFS_CalcWavefront',hdl.value,waveType,pupil, arraywavefront);
I am having trouble with the arraywavefront syntax. when I look at arraywavefront after calling this function, it is still a 2D array of all zeros. I have also tried:
array=zeros(spotsy.value,spotsx.value);
arraywavefront=libpointer('doublePtr',array)
which gives me the error "Error using calllib, Array must be numeric or logical"
For context, here are the parameters from the library:
WFS_CalcWavefront(instrumenthandle, ViInt32 waveType, ViInt32 pupil, float arrayWavefront[]);
for the arrayWavefront parameter:
float[], this parameter returns a 2D array of float containing the data
would love any help or insight anyone can offer! Hope this is enough context/code
0 comentarios
Respuestas (1)
Manish Annappa
el 12 de Jul. de 2017
As I understand from your description, you want 'arraywavefront' to be modified by the shared library. According to the link below 'libpointer' is the correct function to be used for this scenario.
The prototype of the function 'WFS_CalcWavefront' shows that 'arrayWavefront' parameter is of float type. According to the link below, corresponding data type in MATLAB for C type 'float *' is 'singlePtr'. Make changes in 'libpointer' statement accordingly.
1 comentario
Ver también
Categorías
Más información sobre Call C from MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!