The following code saves XYZ points in a separated file but keeping the matrix shape.

p = Flatten[
  Table[{Sin[x], Cos[y], z}, {x, -Pi/2, Pi/2, Pi/2}, {y, -Pi/2, Pi/2, 
    Pi/2}, {z, -Pi/2, Pi/2, Pi/2}], 1]
 Export["B" <> Apply[IntegerString, #2] <> ".dat", #, "Table"] &, 
 Transpose[N[pp], {2, 3, 1}]]

I would like to have the same functionality but saving only the coordinates with positive Z.

  • $\begingroup$ Do you mean you want your Table to go from zero to pi over two {z, 0, Pi/2, Pi/2} instead of -pi over two to pi over two {z, -Pi/2, Pi/2, Pi/2}? $\endgroup$ – Ruud3.1415 Apr 1 '19 at 15:31
  • $\begingroup$ @Ruud3.1415 Thanks to your comment. No, this is just an example. The matrix I want to save is bigger, and Mathematica computes it in a Notebook that imports data from files. $\endgroup$ – user1993416 Apr 2 '19 at 17:31

Your Answer

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

Browse other questions tagged or ask your own question.