Page 1 of 1

how can I define a PiecewiseConstantFunctio using Matlab API

Posted: Wed Aug 28, 2013 12:27 am
by porsasina
Hi every one
I am trying to create a PiecewiseConstantFunction within a Matlab script:

Code: Select all

 PiecewiseConstantFunction(nNodes, tVec, U)

where nNodes is an integer and tVec&U are two vectors (size = 1xnNodes)
When I run my script, it returns this error:
??? No constructor 'org.opensim.modeling.PiecewiseConstantFunction' with matching
signature found.
I tried to replace tVec and U with two matching org.opensim.modeling.ArrayDoubles which didn't solve the problem.
Any ideas?
Thanks
Sina

Re: how can I define a PiecewiseConstantFunctio using Matlab

Posted: Wed Aug 28, 2013 1:29 pm
by aymanh
Hi,

The PiecewiseConstantFunction class has no constructors that take Vector or ArrayDouble, instead it takes double* which is not a Java, Python or scripting construct. Your best bet is to use a sequence of calls similar to the code block below (pulled from one of our examples):

Code: Select all

          
            PiecewiseConstantFunction bangBangControl;
            bangBangControl.addPoint(initialTime,0);
Hope this helps,
-Ayman

Re: how can I define a PiecewiseConstantFunctio using Matlab

Posted: Wed Aug 28, 2013 5:50 pm
by porsasina
Thanks dear Ayman.