How to convert a .Net array into something Matlab can understand?

2 views (last 30 days)
I have managed to write some .net code and compile it to a dll, and call it successfully from Matlab.
The resulting object exposes a number of properties which are all array of string/double/DateTime.
If I do the following in Matlab
z = Library1.DbData.getData(startDt, endDt);
a = cell(z.a_text_field);
Then I can see the results in a no problem.
However, if I do
c = cell(z.dates,'ConvertTypes','System.DateTime');
Then I get
Error using cell
Conversion to double from System.DateTime[] is not possible.
And if I do
d = cell(z.doubles,'ConvertTypes','all');
Then I get
Error using cell
Size inputs must be scalar.
I could hack this and make everything return a stirng, but it seems a bit ugly. How can I make doubles and datetimes work?
  2 Comments
Travis Leith
Travis Leith on 30 Oct 2019
I have answer for the double array. I simply need to do
x = z.some_numeric_field.double;
There doesn't seem to be any equivalent for DateTime though.
Travis Leith
Travis Leith on 30 Oct 2019
Final update: for DateTime I am just returning the Matlab date number instead of a DateTime. Slighlty hacky. Better support for primitave arrays would be nice.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!