MATLAB Answers

Fast copy of Matlab array to .NET array

3 views (last 30 days)
Sébastien Tosi
Sébastien Tosi on 29 May 2016
Commented: Walter Roberson on 30 May 2016
On a modern machine NET.convertArray takes about 1.5 second to convert a 1GB Matlab uint8 1D array... Why is it so slow? Is there a faster way to transfer data from Matlab to a .NET array?

  1 Comment

Sébastien Tosi
Sébastien Tosi on 29 May 2016
Actually my aim is to pass read only data to a C# class loaded in Matlab. Hence ideally it would be faster not to duplicate data but create a .NET array pointing to the Matlab array... is this possible?

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 29 May 2016
"Hence ideally it would be faster not to duplicate data but create a .NET array pointing to the Matlab array... is this possible?"
No. The array data is in-line with some overhead data about bounds and type.

  2 Comments

Sébastien Tosi
Sébastien Tosi on 30 May 2016
Then is there a way to convert/cast a C# array? I noticed that conversion of larger type arrays (e.g. int) of same size in memory is significantly faster. Probably since there are less iterations in the loop and the process is not memory bound.
Walter Roberson
Walter Roberson on 30 May 2016
I do not know about C# arrays.

Sign in to comment.

Sign in to answer this question.