Converting clibarray to matlab array

9 visualizaciones (últimos 30 días)
Boguslaw Wiecek
Boguslaw Wiecek el 22 de Sept. de 2023
Respondida: VINAYAK LUHA el 1 de Dic. de 2023
A similar question has been asked before:
However there was no answer or solution to it. I am using a C++ DLL that returns a large result as an array of type clib.array.libname.Double.and I have tried to create interface with "ReturnCArrays" set to false but as in the question linked above it has no effect. Since the array is large, in excess of 5,000,000 elements, copying it element by element to matlab array takes enormous amount of time in matlab. I cannot leave the result as clib.array since the subsequent processing needs it to be a matlab array. Is there any way to convert clib.array.libname.Double to matalb array in somewhat more reasonable fashion than looping through its elements?

Respuestas (1)

VINAYAK LUHA
VINAYAK LUHA el 1 de Dic. de 2023
Hi Boguslaw,
I underastand that you are calling a C++ ".dll" file in MATLAB which returns an array of type "clib.array.libname.Double". Further, due to the large size of the array, you're looking for a quick and effective method to convert this array into a MATLAB array for additional processing.
Assuming that the data is stored in a ".dat" file, You can leverage MATLAB "memmapfile" function to create a memory map to this file . This memory map can then access this file in the same way it accesses dynamic memory, accelerating file reading and writing, enabling you to work with data in the file as if it were a MATLAB array.
You can refer to the following documentation for more details about the MATLAB "memmapfile" function-
Hope this helps you to convert the described array into a MATLAB array for further processing.
Regards,
Vinayak Luha

Categorías

Más información sobre Performance and Memory en Help Center y File Exchange.

Productos


Versión

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by