[Date Index]
[Thread Index]
[Author Index]
Re: function definition difficulty
*To*: mathgroup at smc.vnet.net
*Subject*: [mg56988] Re: function definition difficulty
*From*: dh <dh at metrohm.ch>
*Date*: Thu, 12 May 2005 02:32:21 -0400 (EDT)
*References*: <d5s9ee$ljp$1@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
Hi Marc,
I think you fooled yourself, your example is correct and working:
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}};
cd[x_] := cdtable[[If[x < 1000., 1, 2], i]];
i = 3; cd[999]
returns 0.911
P.O. It would help if you put a bit more effort into your writing.
sincerely, Daniel
Marc No=EBl wrote:
> 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
as Out[]= 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: NDSolve. SolveDelayed->True**
Next by Date:
** Re: Crossing of 3D functions**
Previous by thread:
**function definition difficulty**
Next by thread:
**Hexagonal Spiral AddOn**
| |