MathGroup Archive 2005

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

Search the Archive

function definition difficulty

  • To: mathgroup at smc.vnet.net
  • Subject: [mg56930] function definition difficulty
  • From: "Marc Noël" <MGE at skynet.be>
  • Date: Tue, 10 May 2005 03:42:45 -0400 (EDT)
  • Reply-to: "Marc Noël" <MGE at skynet.be>
  • Sender: owner-wri-mathgroup at wolfram.com

I have a function say :sz[x_]:= cc (x/1000)^cd    + cfcc, cd and cf are coefficients to be chosen in a list say forcd:cdtable = {{1.941,1.149, 0.911, 0.725, 0.678, 0.74},                  {2.094, 1.098, 0.911, 0.516, 0.305, 0.18}}Here is where it gest tricky :I want to chose the nth part of either the first or the second sublistof cdtable depending on the value of x (the constant "i" being defined beforehand).I triedand cd[x_] :=cdtable[[If[x < 1000., 1, 2],i]]orchoice[x_]:=If[x < 1000., 1, 2]cd[x_]:=cdtable[[choice[x],i]]then if I typei=3;cd[999]I ought to get the result asOut[]= 0.911ihowever, I get Part::pspec:"Part specification If[x <1000., 1, 2] is neither an 
integer nor a list of integers. Plus...can anyone provide a simple way out of this?I have a function say :sz[x_]:= cc (x/1000)^cd    + cfcc, cd and cf are coefficients to be chosen in a list sayforcd:cdtable = {{1.941,1.149, 0.911, 0.725, 0.678, 0.74},                  {2.094, 1.098, 0.911, 0.516, 0.305,0.18}}Here is where it gest tricky :I want to chose the nth part of either the first or the second sublistofcdtable depending on the value of x (the constant "i" being defined beforehand).I triedand cd[x_] :=cdtable[[If[x <1000., 1, 2],i]]orchoice[x_]:=If[x < 1000., 1, 2]cd[x_]:=cdtable[[choice[x],i]]then if I typei=3;cd[999]Iought to get the result asOut[]= 0.911ihowever, I get Part::pspec:"Part specification If[x <1000., 1, 2] isneither an 
integer nor a list of integers. Plus...can anyone provide a simple way out of this?


  • Prev by Date: Re: Partitioning a list from an index
  • Next by Date: Re: StringCases
  • Previous by thread: Re: Converting result to ASCII-art
  • Next by thread: Re: function definition difficulty