# Selecting y-values from xy coordinate grid

Suppose I have a table, u, which is created as follows:

 u = {};
u1 = Table[678, {y, 1, 10}];
u2 = Table[1888, {y, 1, 10}];


It is essentially an x-y grid of values where, for example, x1 = 1 (the x-coordinate at point 1) and x2 = 2. Furthermore, we then have vertical "profiles" of y-values lying "on top" of each x-coordinate, where at x1 = 1 we have the value 678 from y = 1 to y = 10, and at x2 = 2 we have the value 1888 from y = 1 to y = 10:

{{{1, 678}, {1, 678}, {1, 678}, {1, 678}, {1, 678}, {1, 678},
{1, 678}, {1, 678}, {1, 678}, {1, 678}}, {{2, 1888}, {2, 1888},
{2, 1888}, {2, 1888}, {2, 1888}, {2, 1888}, {2, 1888}, {2, 1888},
{2, 1888}, {2, 1888}}}


and u[[1]] is the following:

{{1, 678}, {1, 678}, {1, 678}, {1, 678}, {1, 678}, {1, 678},
{1, 678}, {1, 678}, {1, 678}, {1, 678}}


Now, what I'm hoping to do is at x1 = 1, select all the y-values from y = 1 to y = 10 into a single table, where I'll just have

{678, 678, 678, 678, 678, 678, 678, 678, 678, 678}


Does anyone know how I might do this? Thanks

• Try Cases[u, {1, x_} :> x, -1]
– eldo
Oct 26, 2014 at 13:40

u[[1, All, 2]]
(* {678, 678, 678, 678, 678, 678, 678, 678, 678, 678} *)

u[[2, All, 2]]
(* {1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888} *)

• Thanks very much kguler, worked like a charm. Oct 26, 2014 at 14:16
• @user7388, my pleasure. Thank you for the Accept.
– kglr
Oct 26, 2014 at 14:17
mat = {{{1, 678}, {1, 678}, {1, 678}, {1, 678}}, {{2, 1888}, {2, 1888}, {2, 1888}, {2, 1888}}};

res = Rule @@@ Catenate @ mat // Merge[Identity]


res[2]