Doing an Interpolation through a list of lists into a single function

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.




You just need to tell it what to do with the second argument: Table[interpFunct[k, x_] = Interpolation[list[[k]]][x], {k, 10}]
– wxffles
Nov 19 ’12 at 3:37



@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.
– Pragabhava
Nov 19 ’12 at 3:53



Can I suggest to @wxffles to post and answer instead of a comment, no matter how “trivial”? It helps everybody 8^)
– carlosayam
Nov 19 ’12 at 10:00


2 Answers


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]



Thanks a lot 🙂
– Pragabhava
Nov 19 ’12 at 19:21

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}]



Thanks for taking the time to help. With all this new functions, I’ve a lot of reading to do!
– Pragabhava
Nov 20 ’12 at 16:42