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|improve this question
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|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.