Converting clibarray to matlab array

9 vues (au cours des 30 derniers jours)
Boguslaw Wiecek
Boguslaw Wiecek le 22 Sep 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?

Réponses (1)

VINAYAK LUHA
VINAYAK LUHA le 1 Déc 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

Catégories

En savoir plus sur Performance and Memory dans Help Center et File Exchange

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by