Re: Function of list of functions
- To: mathgroup at smc.vnet.net
- Subject: [mg104090] Re: Function of list of functions
- From: David Bailey <dave at removedbailey.co.uk>
- Date: Mon, 19 Oct 2009 07:10:03 -0400 (EDT)
- References: <hb9k72$rv$1@smc.vnet.net> <hbc8aj$ctt$1@smc.vnet.net> <hben5a$gud$1@smc.vnet.net>
Andrey wrote: > On Oct 17, 3:03 pm, David Bailey <d... at removedbailey.co.uk> wrote: >> 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 i= > t! >> 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 Baileyhttp://www.dbaileyconsultancy.co.uk > > Thank you everybody for your replays. Sorry for my english. I wanted > this, and it is works: > > L = {{1, 2, 3}, {1, 2, 3}, {1, 2, 3}}; > > FuncTestList[n_, v_] := L [[n, v]] > FunRes[v_] := Table[FuncTestList[i, v], {i, 1, 3}] > > Well, using your definitions, I get In[11]:= FunRes[2] Out[11]= {2, 2, 2} I honestly don't see what use this is! Mathematica beginners usually get the most useful answers if they supply a little data (as you did), and then explain what sort of output they would like to obtain. I still don't understand what it is you really want to do! I changed your test data for a reason - you really want all the integers in L to be different - otherwise you can't be sure what Mathematica has done! David Bailey http://www.dbaileyconsultancy.co.uk