Re: An Array of Equation Parameters
- To: mathgroup at smc.vnet.net
- Subject: [mg59903] Re: [mg59861] An Array of Equation Parameters
- From: "David Park" <djmp at earthlink.net>
- Date: Thu, 25 Aug 2005 06:33:36 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Asa, You can separate 'parameters' from 'variables' in a function definition as in the following simple definition. f[a_, b_][x_, y_] := a x + b y f[2, 3][x, y] 2 x + 3 y Now if you had a list of parameters such as... parmlist = {{a, b}, {2, 3}, {Sin[t], Cos[t]}}; You could thread them into your function by... MapThread[(f @@ #)[x, y] &, {parmlist}] {a x + b y, 2 x + 3 y, y Cos[t] + x Sin[t]} Or if you had a table of parm values... parmarray = Table[{a, b}, {a, 1, 3}, {b, 1, 3}]; You could map the function onto the array at level 2. Map[(f @@ #)[x, y] &, parmarray, {2}] {{x + y, x + 2 y, x + 3 y}, {2 x + y, 2 x + 2 y, 2 x + 3 y}, {3 x + y, 3 x + 2 y, 3 x + 3 y}} David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ From: acvwilson at gmail.com [mailto:acvwilson at gmail.com] To: mathgroup at smc.vnet.net This seems like a fairly easy problem in other languages but I can't figure out how to do it in Mathematica. I am trying to set up an array of equation parameters, where each entry in the array is a list of parameters for a function. I also don't know how to get values out of a list to plug into the function. If anyone knows how to solve this problem please help me out. Thanks, Asa