Reading timeseries data in java

1 次查看(过去 30 天)
Kyle Huggins
Kyle Huggins 2020-11-12
编辑: Kyle Huggins 2020-11-12
I'm attempting to read timeseries data generated from a Simulink run using the Compiler SDK to generate a java jar which reads the mat file and passes the object back to the java runtime. the method is simple:
function myData = loadMatlabFile(myPath,varName)
fprintf("Loading %s from %s\n",varName,myPath);
myData = load(myPath,varName);
end
And this gets compiled to a java jar and included in a java project of mine. So this successfully returns an object, but I'm having challenges getting down to the data. So the output data are buses from the simulation, so they get put into a nested struct where the actual data are stored as a timeseries object:
>>structPath.toMyData.myTSObject
timeseries
Common Properties:
Name: 'myTSObject'
Time: [1737x1 double]
TimeInfo: [1x1 tsdata.timemetadata]
Data: [1737x1 double]
DataInfo: [1x1 tsdata.datametadata]
More properties, Methods
When I look at what I think the corresponding object is in java, I see this from toString()
Matlab2Java converter = new Matlab2Java();
myObj = converter.loadMatlabFile(1,myPath,myVar);
MWStructArray data = (MWStructArray)((MWStructArray) myObj[0]).getField("structPath",1);
MWArray toMyData = data.getField("toMyData",1);
MWArray myTSObject = ((MWStructArray) toMyData).getField("myTSObject",1);
It recognizes it as a MWNumericArray, but it appears to be empty. So my question is, am I accessing the data incorrectly, or is there no support for reading timeseries data in java?
  1 个评论
Kyle Huggins
Kyle Huggins 2020-11-12
编辑:Kyle Huggins 2020-11-12
moreover, if I just do a whos on the object in question within the matlab function itself, after it's compiled to a jar, it tells me the object is empty..
myTSObject
Name Size Bytes Class Attributes
myTSObject 0x0 0 double
but a whos from within matlab gives me this:
>>whos('myTSObject')
Name Size Bytes Class Attributes
myTSObject 1x1 28146 timeseries
This really makes me think timeseries objects are not supported with the matlab runtime engine

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Java Package Integration 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by