PiecewiseLinearFunction in MatLab

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Robert Steidl
Posts: 16
Joined: Tue Nov 24, 2015 3:03 am

PiecewiseLinearFunction in MatLab

Post by Robert Steidl » Wed Dec 21, 2016 1:44 am

Hello, again me, and again with a similar issue,

i want to create a linear function for the force in MatLab - the c++ code looks so:

Code: Select all

PiecewiseLinearFunction *forceX = new PiecewiseLinearFunction(2, time, fXofT);
In MatLab i can acces to the constructor like:
Force = PieceWiseLinearFunction();
but how can i add the parameters time and fXofT in MatLab??

User avatar
Thomas Uchida
Posts: 1802
Joined: Wed May 16, 2012 11:40 am

Re: PiecewiseLinearFunction in MatLab

Post by Thomas Uchida » Wed Dec 21, 2016 2:32 am

Have you tried addPoint()? There's a C++ example that uses addPoint() here: https://github.com/opensim-org/opensim- ... e.cpp#L212; here's the documentation: https://simtk.org/api_docs/opensim/api_ ... ction.html.

User avatar
Robert Steidl
Posts: 16
Joined: Tue Nov 24, 2015 3:03 am

Re: PiecewiseLinearFunction in MatLab

Post by Robert Steidl » Wed Dec 21, 2016 4:53 am

Thank you,

thats a good point - for my understanding, if I have the timepoints at 0 and 2 and the corresponding force at 0 and 15 my code should look like:

Code: Select all

Force = PiecewiseLinearFunction();
Force.addPoint(0, 0);
Force.addPoint(2, 15);
Am I right?

User avatar
Thomas Uchida
Posts: 1802
Joined: Wed May 16, 2012 11:40 am

Re: PiecewiseLinearFunction in MatLab

Post by Thomas Uchida » Thu Dec 22, 2016 10:39 pm

Yes, that code looks correct. I recommend getting into the habit of running tests using simple models and verifying that the answers are what you expect before trying to tackle more complex problems.

POST REPLY