MathGroup Archive 2005

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

Search the Archive

Re: Matrices and Conditional Statements


On Tuesday, October 18, 2005 at 02:44 GMT -0400, Gregory Lypny wrote:

>      If I have an n x m array called X, how can I create another
> array, Y, whose rows are those rows in X whose 8th column contains  
> the word "red" and whose 11th column is a number greater than 9?

(* Generate some Random data *)
list1 = Table[
      Flatten[
        {Table[Random[], {7}],
          If[2*Random[] > 1, "red", "green"],
          Table[Random[], {2}],
          Random[]*18}], {100}];

(* Filter the data *)
list2 = Select[
    list1,
    StringMatchQ[#[[8]], "red", IgnoreCase -> True] && #[[11]] > 9 &]


  • Prev by Date: Re: Function, Command, Operator, Object...etc.
  • Next by Date: Re: Matrices and Conditional Statements
  • Previous by thread: Matrices and Conditional Statements
  • Next by thread: Re: Matrices and Conditional Statements