Changing ArrayDouble to Matrix in MATLAB

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Mohammadhossein Akhavanfar
Posts: 19
Joined: Mon Oct 16, 2017 9:11 am

Changing ArrayDouble to Matrix in MATLAB

Post by Mohammadhossein Akhavanfar » Wed Mar 13, 2019 4:26 pm

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

User avatar
Dimitar Stanev
Posts: 1096
Joined: Fri Jan 31, 2014 5:14 am

Re: Changing ArrayDouble to Matrix in MATLAB

Post by Dimitar Stanev » Thu Mar 14, 2019 1:16 am

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);

POST REPLY