MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: best solution?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg22905] Re: best solution?
  • From: Eckhard Hennig <hennig at itwm.uni-kl.de>
  • Date: Thu, 6 Apr 2000 02:04:26 -0400 (EDT)
  • Organization: ITWM
  • References: <8ce9t3$14a@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Peter Weijnitz schrieb in Nachricht <8ce9t3$14a at smc.vnet.net>...
>I have a function e.g F[a,b,c,x] =a Sin[b x +c]  and a number of parameter
>triplets
>k={{a1,b1,c1},{a2,b2,c2},{a3,b3,c3},....}.
>I would like to feed my function the parameter values in an good and simple
>way, how?
>
>(Picking out the elements like k[[3,2]]=b3 e.t.c is not what I want.)
>/Peter

Peter,

you can use the Mathematica command Apply with a level specification to
achieve what you want. Of course, this is only one of many possible
solutions; an alternative is shown in In[4].


In[1]:= F[a_, b_, c_, x_] := a Sin[b x + c]

In[2]:= k = {{a1, b1, c1}, {a2, b2, c2}, {a3, b3, c3}};

In[3]:= Apply[F[##, x]&, k, 2]

Out[3]= {a1 Sin[c1 + b1 x], a2 Sin[c2 + b2 x], a3 Sin[c3 + b3 x]}

In[4]:= F[Sequence @@ #, x]& /@ k

Out[4]= {a1 Sin[c1 + b1 x], a2 Sin[c2 + b2 x], a3 Sin[c3 + b3 x]}


HTH,

  Eckhard

-----------------------------------------------------------
Dipl.-Ing. Eckhard Hennig      mailto:hennig at itwm.uni-kl.de
Institut fuer Techno- und Wirtschaftsmathematik e.V. (ITWM)
Erwin-Schroedinger-Strasse,  67663 Kaiserslautern,  Germany
  Voice: +49-(0)631-205-3126    Fax: +49-(0)631-205-4139
    http://www.itwm.uni-kl.de/as/employees/hennig.html

     ITWM - Makers of Analog Insydes for Mathematica
        http://www.itwm.uni-kl.de/as/products/ai
-----------------------------------------------------------





  • Prev by Date: Re: best solution?
  • Next by Date: Mathematica NDSolve max number of grid points error
  • Previous by thread: Re: best solution?
  • Next by thread: Re: best solution?