|Subject:||Re: Convert array to function|
|Date:||Fri, 19 Dec 2014 09:39:41 -0500|
I have a problem and assume there's a simple solution. But I neither
know octave nor maths that well. Maybe some of you guys can help
I have a curve that is described as a vector v with n-elements, each
containing a pair:
v=[0,0; 2,2; 4,2; 6,6; 10,6]
0 2 4 6 8 10
I am only interested in the x-range [0:10] meaning the values below
0 and above 10 can be ignored.
Vector v is given and I have to define a function that evaluates to
the points described by the vector. The points are always connected
by straight lines. So the function should (with the example values
for v as stated above) at point 1 evaluate to 1, at point 2 evaluate
to 2, at point 8 evaluate to 6, etc.
The pairs are not necessarily equally spaced and the number of
elements in v is not constant. (This will be automated and the v is
the input I receive.)
The question: Is there an octave function which I can feed the
vector with pairs (v) and obtain a function which I can evaluate at
any point within the range?
I looked into linear approximation, but that gives me a straight
line through the points and no the required “steps”, thus
introducing a very high error. I also found that polynom or spline
approximation (using splinefit or polyfit) do not yield acceptable
results. Any ideas?
I am happy to provide further information or clarify things if
Help-octave mailing list
|[Prev in Thread]||Current Thread||[Next in Thread]|