Filter löschen
Filter löschen

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

2 Ansichten (letzte 30 Tage)
Travis Leith
Travis Leith am 30 Okt. 2019
Kommentiert: Travis Leith am 30 Okt. 2019
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 Kommentare
Travis Leith
Travis Leith am 30 Okt. 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 am 30 Okt. 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.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Call Web Services from MATLAB Using HTTP finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by