I'm trying to plot the following function:

  ymin = 0, width=17cm, height=19cm, grid = major,
  use units,  x unit=mm,  y unit=j.u, xlabel=x,  ylabel=I]

{ (sin(120*x)/(120*x)*cos(100*x))^2};


What I get is this:

enter image description here

and what should I gest is that:

enter image description here

They look pretty simmilar but the wrong figure y values ranges from 0 to 3x10^(-4) when they sould range form 0 to 1. I already solved the readian - degrees problem. But this one is something above my skilz :p.

  • I dont think that's the problem. At x=0 sin(120*x)/(120*x) tends to unity so there is no singularity at this point. – Arthur Dec 29 '13 at 18:27
  • I tried tweaking "samples". I got the same figure only smoother. "samples at" wont help either. – Arthur Dec 29 '13 at 18:31
  • Are you sure that's the correct function? I get this Wolfram Alpha plot – percusse Dec 29 '13 at 18:48
  • Your input is incorrect. It should be: Wolfram Alpha. I wonder If anyone tried my code and got the same result as mine. Anyone ? – Arthur Dec 29 '13 at 19:36

Ok I solved the propblem. The units in trigonometric functions must be converted to degrees. But the denominator must be kept in radians since it is not an argument of trigonometric fuction. Here is correct function.


I my opinion this degrees - radians units change causes lots of problems. Why they don't fix it and use radians?

| improve this answer | |
  • the deg/rad problem is huge, I agree. But how would you change it? Changing the default is impossible; it would break existing pictures. Adding a further option of sorts "trig unit=deg|rad" would be possible, but since it would not become a default, nobody would use it. Probably. Which way to "fix it" would you accept/expect as end-user? Something like \pgfplotsset{compat=1.9, trig unit=rad} in your preamble? that would be feasible... [this key does not exist currently!] – Christian Feuersänger Dec 30 '13 at 7:59
  • You are right. Setting radians as default will effect the existing files and will cuse yet more confussion. I think that adding an option to a plot is a good solution since you can choose units for every single plot. Pretty useful and I think that people will learn to use it like they learn to use 'deg()'. The solution with preambule is also good, much more elegant (less typing) and quick. Downside is that you have to use rad/deg in the entire document. One way or another those solutions are much better than 'deg()' which is verry uncomfortable. – Arthur Dec 30 '13 at 16:31
  • You welcome. I hope that will help. – Arthur Dec 30 '13 at 17:43

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.