2
$\begingroup$

I need to export my data into a .txt document to import it in $\LaTeX$. For a given M, I used the follow code to export:

data =
  Cases[
    Plot[M[n1, d1, n2, d2, nb],
     {alpha, 0, 2 Pi},
     PlotPoints -> 3000, MaxRecursion -> 0],
    Line[data_] :> data, -4, 1][[1]];
    Export["M_AB.txt", data, "Table"]

The problem is that the whole range is not exported. The range of the .txt file is from 0 to 1.566 (1.5708 would be $\pi/2$). Then i tried to set the range manually by using {0, 2 Pi}, {Pi/2, 2 Pi}, {3/2 Pi, 2 Pi}. Then I had gaps in the plots. Here is a picture how it looks like in Mathematica (left) and how it looks in $\LaTeX$ with the gaps, after adding it manually (right). enter image description here

Why doesn't Mathematica export the whole range?

$\endgroup$
8
  • $\begingroup$ Welcome to Mathematica.SE! 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$
    – user9660
    Oct 26, 2015 at 13:56
  • $\begingroup$ Possible duplicate of mathematica.stackexchange.com/questions/19859/… $\endgroup$
    – Pillsy
    Oct 26, 2015 at 14:04
  • $\begingroup$ Looking again at the previous answer, it looks like it doesn't address this specific question. However, it would help if you provided us with the definition of M so we can investigate in more detail. $\endgroup$
    – Pillsy
    Oct 26, 2015 at 14:31
  • 2
    $\begingroup$ We need the definition of M. If you try substituting an arbitrary built in function (e.g. Sin[alpha]) in your export routine, does that work? I tried that on my side and I did get a list of 3000 points as expected. Was the MMA plot you show generated using the exact same parameters as the one in the Cases expression? I am worried that disabling the adaptive routines (MaxRecursion -> 0) might make Plot partially miss the peaks in your function. $\endgroup$
    – MarcoB
    Oct 26, 2015 at 14:55
  • 2
    $\begingroup$ Since you are setting MaxRecursion -> 0 anyway (which prevents Plot from doing adaptive sampling), why are you generating the function values in such a complicated, roundabout manner? Why don't you just use Table[{x, f[x]}, {x,...}] instead? $\endgroup$
    – Szabolcs
    Oct 26, 2015 at 14:57

0

Browse other questions tagged or ask your own question.