Re: newbie question on functions

*To*: mathgroup at smc.vnet.net*Subject*: [mg51763] Re: [mg51750] newbie question on functions*From*: Bob Hanlon <hanlonr at cox.net>*Date*: Mon, 1 Nov 2004 02:52:44 -0500 (EST)*Reply-to*: hanlonr at cox.net*Sender*: owner-wri-mathgroup at wolfram.com

Functional programming would be simpler. ratio[mat_?MatrixQ, col1_Integer, col2_Integer] := (Log[2,#[[1]]/#[[2]]]& /@ mat[[All,{col1,col2}]]) /; 1<=col1<=Length[mat[[1]]] && 1<=col2 <= Length[mat[[1]]]; intensity[mat_?MatrixQ, col1_Integer, col2_Integer] := (Log[2,#[[1]]*#[[2]]]& /@ mat[[All,{col1,col2}]]) /; 1<=col1<=Length[mat[[1]]] && 1<=col2 <= Length[mat[[1]]]; fmicroarray=Array[fma,{3,19}]; ratio[fmicroarray,18,19] {Log[fma[1, 18]/fma[1, 19]]/Log[2], Log[fma[2, 18]/fma[2, 19]]/Log[2], Log[fma[3, 18]/fma[3, 19]]/Log[2]} intensity[fmicroarray,18,19] {Log[fma[1, 18]*fma[1, 19]]/Log[2], Log[fma[2, 18]*fma[2, 19]]/Log[2], Log[fma[3, 18]*fma[3, 19]]/Log[2]} Bob Hanlon > > From: Todd Allen <genesplicer28 at yahoo.com> To: mathgroup at smc.vnet.net > Date: 2004/10/31 Sun AM 01:17:36 EST > To: mathgroup at smc.vnet.net > Subject: [mg51763] [mg51750] newbie question on functions > > Hi all, > > I have what is probably a nieve question, but it is giving me some difficulty. I am trying to generate a function in which I pass two columns of information from a matrix to this function to perform some calculations. I can successfully pass the data and get the resulting calculation......but the problem is the function returns the results but does not save the results in memory to perform subsequent calculations with. How can I get the function to keep the result? Is there a way to assign the function output to a new variable before mathematica discards the results. Does this behavior have anything to do with the Head of the function being symbolic, rather than say a list?? > > Below is the relevant code: > > SetAttributes[ratio,Listable]; > SetAttributes[intensity,Listable]; > > ratio[cy3_,cy5_]:=Table[Log[2,(cy3/cy5)]]//N; > intensity[cy3_,cy5_]:=Table[Log[2,(cy3*cy5)]]//N; > ratio[Table[fmicroarray[[i,18]],{i,1,Length[fmicroarray]}], > Table[fmicroarray[[i,19]],{i,1,Length[fmicroarray]}]] > > > I appreciate any insight you might have. Thanks. > > Todd > >