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
Changing ArrayDouble to Matrix in MATLAB
- Mohammadhossein Akhavanfar
- Posts: 19
- Joined: Mon Oct 16, 2017 9:11 am
- Dimitar Stanev
- Posts: 1096
- Joined: Fri Jan 31, 2014 5:14 am
Re: Changing ArrayDouble to Matrix in MATLAB
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);