Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: newbie question on functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg51761] Re: [mg51750] newbie question on functions
  • From: "David Park" <djmp at earthlink.net>
  • Date: Mon, 1 Nov 2004 02:52:41 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Todd,

First, if you check the attributes of Times and Log you will find they are
both Listable as are most basic built-in Mathematica operations.

Attributes[Times]
{Flat, Listable, NumericFunction, OneIdentity, Orderless, Protected}

Attributes[Log]
{Listable, NumericFunction, Protected}

Second, the Table function in the two routines isn't really doing anything
since there is no iterator as a second argument. You can calculate your
results directly and you can store them under a symbol, say ratio1 as
follows with some sample data.

list1 = Table[Random[Real, {2, 20}], {5}]
list2 = Table[x, {x, 1, 5}]

{14.5284, 4.74482, 3.10836, 10.8741, 19.8282}
{1, 2, 3, 4, 5}

ratio1 = Log[2, list1/list2]
{2.37297, 2.21692, 2.21481, 1.49147, 1.94953}

Now, ratio1 contains the results.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/






From: Todd Allen [mailto:genesplicer28 at yahoo.com]
To: mathgroup at smc.vnet.net

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




  • Prev by Date: Re: Mathematica's (and others) ancient widget toolkit ... why?
  • Next by Date: Re: bimodal ditribution form counting signs of Pi digits differences
  • Previous by thread: Re: newbie question on functions
  • Next by thread: Re: newbie question on functions