Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: Function of list of functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg104060] Re: Function of list of functions
  • From: David Bailey <dave at removedbailey.co.uk>
  • Date: Sat, 17 Oct 2009 07:03:53 -0400 (EDT)
  • References: <hb9k72$rv$1@smc.vnet.net>

Andrey wrote:
> Hello!
> May be anybody can help me. So, I have this:
> 
> L = {{1, 2, 3}, {1, 2, 3}, {1, 2, 3}};
> Fun1[t_] := ListPlot[L[[1, t]]];
> Fun2[t_] := ListPlot[L[[2, t]]];
> Fun3[t_] := ListPlot[L[[3, t]]];
> 
> FunRes[t_] := {Fun1[t], Fun2[t], Fun3[t]};
> 
> Everything is ok, BUT if I want to add element to list of FunRes[t_]
> in loop, I have an error? so I mean this:
> 
> FunRes[t_] := {};
> For[i = 1, i <= 3, i++,
>  	{Subscript[Fun, i][t_] := ListPlot[L[[i, t]]],
>   	AppendTo[FunRes[t], Subscript[Fun, i][t]]}]
> 
> Please, help me, where I am wrong?
> 
It is very hard to figure out what you want to achieve here. Here are a 
few thoughts:

Let's start with a list where we can tell what we are plotting:

L = {{1, 2, 3}, {10, 20, 30}, {100, 200, 300}};

This will plot the second sublist:

ListPlot[L[[2]]]

Here is a function that will plot the n'th sublist:

fun[n_] := ListPlot[L[[n]]]

e.g.

fun[3]

Note that in your code FunRes[t] evaluates a function, so it makes 
absolutely no sense to use AppendTo on the result!

Tell us what you really want to do, and someone will tell you how to do it!

BTW, it is highly recommended that you don't use variable names that 
start with a capital letter (unless you use a special character further 
in the name) to avoid confusion with Mathematica's symbols.

David Bailey
http://www.dbaileyconsultancy.co.uk


  • Prev by Date: Re: Subscript[x,1] value do not get cleared using Clear["Global`*"] but get removed using Remove["Global`*]
  • Next by Date: Re: Generic Mapping Tools and Mathematica
  • Previous by thread: Function of list of functions
  • Next by thread: Re: Function of list of functions