Return Struct from .net dll
6 次查看(过去 30 天)
显示 更早的评论
I have a .net DLL (C#) that receives real-time (and lots) of data over TCP from a sensor. The data is coming as arrays of custom objects. (call it a SensorPacket, that has about 20 fields, mostly float and int).
I have been sending this up to matlab via events (works fine). But Matlab sees them as an array of .NET objects. I would prefer to send this up as a array of struct. How?
yes, one can convert this array to a cell array via:
but that still leaves this as a cell array of .net objects. Can one cast the objects so that I can get the values?
and better would be to send a cell/array of struct.
I had tried converting this to JSON, and using a matlab JSON reader to convert to structs, but this is very very slow: http://www.mathworks.com/matlabcentral/fileexchange/33381-jsonlab--a-toolbox-to-encode-decode-json-files
Don't laugh, but I am thinking of using the DLL to write a .MAT file, and then send up the handle to that to Matlab. This writer might work: http://www.mathworks.com/matlabcentral/fileexchange/16319-csmatio--mat-file-i-o-api-for-net-2-0
In the following page, it says I can return a struct or a class, but my experience is that this returns a System.Object
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 JSON Format 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!