[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Convert array to function

From: Doug Stewart
Subject: Re: Convert array to function
Date: Fri, 19 Dec 2014 09:39:41 -0500

On Fri, Dec 19, 2014 at 6:36 AM, Marco <address@hidden> wrote:

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]

ASCII-art visualised:

  6|           xxxxxxxxx
   |          x
  4|         x
   |        x
  2|   xxxxx
   |  x
   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

When trying to convert data to a function it is good to know (from where the
 data is collected) what kind of curve to expect.

Is it exponential, leaner, polynomial  or reciprocal etc.

So the best way to start is to tell us what, where, how etc , your data is.
DASCertificate for 206392

reply via email to

[Prev in Thread] Current Thread [Next in Thread]