MathGroup Archive 2004

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

Search the Archive

Re: need to call data from a list as input but need it in vector form not list form

On Sep 15, 2004, at 1:50 AM, T. wrote:

> Suppose I have just generated a list named "list" and the output is as
> follows.
> {{0.161299}, {0.122965}, {0.055712}, {0.0448334}, {-0.00538706}}
> I want to use this data in the form
> {0.161299, 0.122965, 0.055712, 0.0448334, -0.00538706}
> however i can't call it in with list[[i]] because I just get the
> {{},{},{},{}} form with those extra brackets.

Use Flatten[list] or list[[All,1]].

>   I guess I have a list
> and I am trying to convert it to a vector form right?  Sorry if my
> definitions are confused.

One way of specifying your problem is you have a rank 2 list and you 
want a rank 1 list, or you have a matrix and you want a vector in row 
(or column in this case they're the same thing) major order.  At any 
rate a list in Mathematica is any expression with the head List, 
regardless of its structure.  What you are concerned about is the 
structure of a list, in which case you can refer to its rank in the 
case that it makes sense to think of it as a vector, matrix or other 
form of tensor.  If you don't have a regular structure such a list of 
the form {{},{{}},{{{}}},{}} then you can refer to its depth or tree 
form.  In either case, Flatten and Partition are usually the functions 
used to modify a list's structure.  Incidentally they work on 
expressions that don't have the head List.  I hope this helps.



  • Prev by Date: Re: GuiKit & GraphEdit
  • Next by Date: Re: Plot[f, {x,a,b] vs Plot[{f},[x,a,b]
  • Previous by thread: need to call data from a list as input but need it in vector form not list form
  • Next by thread: Primed Variables in Mathematica