Page 1 of 1

MATLAB OpenSim indexing

Posted: Mon Jan 02, 2023 1:17 am
by shivangi2208
Hello,
OpenSim indexes start from 0 whereas MATLAB's start from 1, however in the examples provided with OpenSim package (like createActuatorsFile.m), the index starts from 0. Kindly let me know how to achieve this. Because whenever I start indexing with 0 in my MATLAB code usign OpenSim libraries I get the following error.

"Array indices must be positive integers or logical values."

Regards,
Shivangi

Re: MATLAB OpenSim indexing

Posted: Mon Jan 02, 2023 12:48 pm
by aymanh
Hi Shivangi,

This message doesn't come from OpenSim but from MATLAB which suggests you're trying to use MATLAB index on an OpenSim object. Fundamentally you should only use the OpenSim methods to access OpenSim objects, for example using methods like
get(index)
rather than direct indexing.

Hope this helps,
-Ayman

Re: MATLAB OpenSim indexing

Posted: Fri Jan 06, 2023 4:05 am
by shivangi2208
Thank you, Ayman for your reply.

Regards,
Shivangi