Page 1 of 1

Error reading file with TRCFileAdapter in matlab

Posted: Wed Sep 09, 2020 10:20 pm
by hwunimelb
Hi everyone,

Using OpenSim 4.1, I'm trying to use the read function of the TRCFileAdapter class to import the data from a .trc file into Matlab using the code:

Code: Select all

trctimeSeriesTable = org.opensim.modeling.TRCFileAdapter.read("W101.trc");
running the above, however, returns this error:

Code: Select all

Check for missing argument or incorrect argument data type in call to function 'read'.
From what I understand from reading the API (https://simtk.org/api_docs/opensim/api_ ... apter.html), there is only one input argument required which is a string, which I believe I am inputting correctly. Am I mistaken? Or is there something I'm missing? I don't have a lot of experience with C++ syntax.

I'd appreciate any and all help with the issue.

Re: Error reading file with TRCFileAdapter in matlab

Posted: Thu Sep 10, 2020 1:26 am
by mitkof6
Hi Henry,

Your approach seems OK and the API call is correct. I would try to create the TRCFileAdapter first, because it is a class object and then read the file. Maybe Matlab expects that TRCFileAdapter is constructed since classes expect an implicit "self" argument that must be passed to the constructor (do not bother to understand this). You can try the following:

Code: Select all

trcAdapter = org.opensim.modeling.TRCFileAdapter()
trctimeSeriesTable = trcAdapter.read("W101.trc")

Re: Error reading file with TRCFileAdapter in matlab

Posted: Thu Sep 10, 2020 9:31 am
by aymanh
Hi Henry,

The read method is part of the generic interface that returns a collection of TimeSeriesTable(s) that you need to dig into in order to fish out the TimeSeriesTable of interest. The recommended way to avoid this altogether is to construct the TimeSeriesTable of the specific type directly from the file as described here:
https://simtk-confluence.stanford.edu/d ... DatatoFile

Hope this helps,
-Ayman

Re: Error reading file with TRCFileAdapter in matlab

Posted: Fri Sep 11, 2020 10:48 pm
by hwunimelb
Thanks Ayman, your solution worked. I appreciate the help.