MATLAB OpenSim indexing

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Shivangi Giri
Posts: 51
Joined: Sun Jul 02, 2017 3:04 am

MATLAB OpenSim indexing

Post by Shivangi Giri » Mon Jan 02, 2023 1:17 am

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

Tags:

User avatar
Ayman Habib
Posts: 2248
Joined: Fri Apr 01, 2005 12:24 pm

Re: MATLAB OpenSim indexing

Post by Ayman Habib » Mon Jan 02, 2023 12:48 pm

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

User avatar
Shivangi Giri
Posts: 51
Joined: Sun Jul 02, 2017 3:04 am

Re: MATLAB OpenSim indexing

Post by Shivangi Giri » Fri Jan 06, 2023 4:05 am

Thank you, Ayman for your reply.

Regards,
Shivangi

POST REPLY