Page 1 of 1

Changing ArrayDouble to Matrix in MATLAB

Posted: Wed Mar 13, 2019 4:26 pm
by makhavanfar
Hello All,

I am working with OpenSim API through MATLAB. If A is my storage, I use this command to get states vector @ time t:
B=A.getStateVector(t-1);
C=B.getData();

C is an arraydouble variable. I can access to the element m by this command:
C.getitem(m-1)

However, I don't want to use a for loop to access all elements of C. Is there any way that I can easily get C as a matrix in MATLAB?

Thank you in advance,

Mohammad

Re: Changing ArrayDouble to Matrix in MATLAB

Posted: Thu Mar 14, 2019 1:16 am
by mitkof6
You can get a row as an SimTK::Vector or OpenSim::Array or double*, but you cannot get a pure Matlab type array. I would get the row (C++) as follows:

Code: Select all

 auto columns = storage.getColumnLabels();
 Vector row(columns.getSize() - 1);  // ignore time label
 storage.getDataAtTime(t, columns.getSize() - 1, row);