2
$\begingroup$

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.

$\endgroup$
  • 1
    $\begingroup$ Use Partition ? $\endgroup$ – b.gates.you.know.what Sep 12 '12 at 16:54
  • $\begingroup$ thanks, you were right, Partition does the job $\endgroup$ – Harald Sep 12 '12 at 18:49
1
$\begingroup$
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
$\endgroup$
  • $\begingroup$ ah, Partition is the key... Thanks a lot $\endgroup$ – Harald Sep 12 '12 at 18:48
  • $\begingroup$ @Harald there are easier ways. See edit $\endgroup$ – Dr. belisarius Sep 12 '12 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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