Reading timeseries data in java
显示 更早的评论
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
2020-11-12
编辑:Kyle Huggins
2020-11-12
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Java Package Integration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!