Suppose I have a list of lists, i.e.

list = Table[{x, x^ k}, {k, 1, 10}, {x, 0, 1, 0.05}];

and I want to interpolate each of the lists by a function using Interpolation (or another appropriate function). Is there a way to create a function of k and x, i.e

Table[interpFunct[k] = Interpolation@list[[k]],{k,1,10}]

so I have interpFunct[1,x], interpFunct[2,x], etc. available?

I know I can interpolate the surface but the mesh is not structured, which leads to new difficulties that have nothing to do with my needs.

Any advice will be very helpfull.

  • 3
    $\begingroup$ You just need to tell it what to do with the second argument: Table[interpFunct[k, x_] = Interpolation[list[[k]]][x], {k, 10}] $\endgroup$
    – wxffles
    Nov 19, 2012 at 3:37
  • $\begingroup$ @wxffles Crap, I knew my q. was kinda lame. Thanks a lot. Two things (lame as well): 1. Is there a way to define the domain of interpolation? 2. Even though it is a dumb question, I'll accept your comment as an answer. $\endgroup$
    – Pragabhava
    Nov 19, 2012 at 3:53
  • $\begingroup$ Can I suggest to @wxffles to post and answer instead of a comment, no matter how "trivial"? It helps everybody 8^) $\endgroup$
    – carlosayam
    Nov 19, 2012 at 10:00

2 Answers 2


As in the comments here's an answer, plus some variations:

Table[interpFunct[k, x_] = Interpolation[list[[k]]][x], {k, Length[list]}]

(interpFunct[#, x_] = Interpolation[list[[#]]][x]) & /@ Range[Length[list]]

Scan[(interpFunct[#, x_] = Interpolation[list[[#]]][x]) &, Range[Length[list]]]

MapIndexed[(interpFunct[#2[[1]], x_] = Interpolation[#1][x]) &, list]

I'd normally use Scan[] for the purpose of building a bunch of functions, but the indexing makes the use of MapIndexed[] so tempting:

list = Table[{x, x^k}, {k, 1, 10}, {x, 0, 1, 0.05}];

MapIndexed[With[{k = First[#2]}, interpFunct[k] = Interpolation[#1]] &, list];

Plot[Table[interpFunct[k][x], {k, 10}] // Evaluate, {x, 0, 1}]

plots of interpolants

  • $\begingroup$ Thanks for taking the time to help. With all this new functions, I've a lot of reading to do! $\endgroup$
    – Pragabhava
    Nov 20, 2012 at 16:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.