1

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.

Pragabhava
  • 1,619
  • 15
  • 24
  • 3
    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 03: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 03: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 Answers2

4

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

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
1

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]
wxffles
  • 14,246
  • 1
  • 43
  • 75