Re: List of Interpolated functions inside plot

*To*: mathgroup at smc.vnet.net*Subject*: [mg24844] Re: List of Interpolated functions inside plot*From*: "Allan Hayes" <hay at haystack.demon.co.uk>*Date*: Wed, 16 Aug 2000 03:24:09 -0400 (EDT)*References*: <8naq28$esp@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Chris, After xyinterp[m_] := Interpolation[Table[{x, Sin[m x]}, {x, -5, 5, 0.25}]]; Plot[Table[xyinterp[m][x], {m, 1, 10, 3}], {x, -5, 5}] does not work because it evaluates as follows: the unevaluated Table[xyinterp[m][x],{m,1,10,3}] is examined; it is not a list; so Mathematica expects that when x is set to a real number then Table[xyinterp[m][x],{m,1,10,3}] will be a real number -- which it is not. But Plot[Evaluate[Table[xyinterp[m][x], {m, 1, 10, 3}]], {x, -5, 5}] works because before any check is made, Evaluate[Table[xyinterp[m][x],{m,1,10,3}]] evaluates to {xyinterp[1][x], xyinterp[4][x],xyinterp[7][x], xyinterp[10][x] }; so the check finds a list and evaluates this successfully. However please note that this way x might pick up an existing definition x = 4; Plot[Evaluate[Table[xyinterp[m][x], {m, 1, 10, 3}]], {x, -5, 5}] To avoid this we can use Block Block[{x}, Plot[Evaluate[Table[xyinterp[m][x], {m, 1, 10, 3}]], {x, -5, 5}]] -- Allan --------------------- Allan Hayes Mathematica Training and Consulting Leicester UK www.haystack.demon.co.uk hay at haystack.demon.co.uk Voice: +44 (0)116 271 4198 Fax: +44 (0)870 164 0565 "Krautschik, Chris G" <krautschikc at intel.co.jp> wrote in message news:8naq28$esp at smc.vnet.net... > If have defined the following interpolation for arbitrary integer m: > > xyinterp[m_] := Interpolation[Table[{x, Sin[m x]}, {x, -5, 5, 0.25}]]; > > I can plot a number of the interpolated functions on one plot as follows: > > Plot[ {xyinterp[1][x], xyinterp[2][x], xyinterp[3][x]}, {x,-5,5} ]; > > Let's say I want to plot a large number of the functions of integer m but I > like to use the Table command since typing can become quite tedious: > > Then > > Plot[ Table[xyinterp[m][x], {m, 1, 10, 3}],{x,-5,5} ] > > doesn't work because the value of x needs to be defined pior to the > execution of the Table command. I have tried various forms of Hold but that > doesn't seem to work. > > Any help or suggestions on how to make this work would be appreciated. > > thanks, > Chris > > >