Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

A file consists out of (x,y,z) data and I need the z-values arranged like this:

{{z[1],z[2],...z[idimx]},{z[idimx+1],z[idimx+2],...z[idimx*2]},{....}}

With

y=data[[All,2]]; z = data[[All, 3]];
iall=Length[z];
idimy=Length@Position[y,0];
idimx=iall/iy;

I get the dimensions of the array: {idimx,idimy}. But how can I now arrange it's elements? Thanks a lot.

share
1  
Use Partition ? –  b.gatessucks Sep 12 '12 at 16:54
    
thanks, you were right, Partition does the job –  Harald Sep 12 '12 at 18:49

1 Answer 1

up vote 1 down vote accepted
data = Thread[Join[{Tuples[{Range[3], Range[0, 9]}], Range[30]}]] /. {{a_, b_}, c_} -> {a, b, c}
y = data[[All, 2]];
idimy = Length@Position[y, 0];
idimx = Length@data/idimy;
zp = Partition[data[[All, 3]], idimx]
ListLinePlot@zp

Mathematica graphics

Edit

Easier:

data = ....
zp = Split[data, #1[[2]] < #2[[2]] &][[All, All, 3]]
ListLinePlot@zp
share
    
ah, Partition is the key... Thanks a lot –  Harald Sep 12 '12 at 18:48
    
@Harald there are easier ways. See edit –  belisarius Sep 12 '12 at 19:18

This site is currently not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .