Clear Filters
Clear Filters

Reading timeseries data in java

4 views (last 30 days)
Kyle Huggins
Kyle Huggins on 12 Nov 2020
Edited: Kyle Huggins on 12 Nov 2020
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 Comment
Kyle Huggins
Kyle Huggins on 12 Nov 2020
Edited: Kyle Huggins on 12 Nov 2020
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

Sign in to comment.

Answers (0)

Categories

Find more on Java Package Integration in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!