Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to draw a frequency modulated sinusoidal in a polar domain with the following code.

\documentclass[tikz,border=10]{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}

    \def\rad{5.5}
    \def\amp{1.0}
    \def\n{11}
    \def\myphi{90}

    \draw [domain=0:6.29,samples=500,smooth] plot (xy polar cs:angle=\x r,
        radius={\rad+\amp*cos(\n*\x r+sin(\n*\x r+\myphi)+\myphi)});

\end{tikzpicture}

\end{document}

When I compile this, however, the inner sinusoidal is completely ignored. In other words, tikz seems to read the following line instead.

radius={\rad+\amp*cos(\n*\x r+\myphi)});

Why does this happen, and how do I get the intended result?

Edit: Frequency modulation is a mathematical operation which modifies the argument of a function. In my example, the argument of the cosine function is modified by a sine function. As explained, this inner sine function is, for some reason, ignored when I compile the code. I'm curious about why, and I wish to know how I can draw a function where nothing is ignored.

Visualized by Wolfram Alpha, the first image shows the intended function, and the second image shows the function LaTeX compiles. They are not the same.

Edit2: I have shortened and changed the example. It should now be easier to read the function in the code above. Hopefully I didn't remove anything essential.

enter image description here enter image description here

share|improve this question
2  
All users are not familiar with frequency modulated sinusoidal graph. What do produce your code? Please give us an example. –  ferahfeza Apr 2 at 22:04
1  
Consider using PGFPlots for doing polar plots: tex.stackexchange.com/questions/146671/… –  juliohm Apr 2 at 22:12
    
I included the two images of the two figures you linked to. They seem identical to me and identical to the function I get running your MWE (just missing the axis). –  Peter Grill Apr 2 at 23:29
    
@Peter, by removing the Wolfram Alpha (WA) links, you also removed the expressions as shown in WA, which should indeed make it clearer that they are not the same. –  eiterorm Apr 2 at 23:35
    
Have added the links back. Sorry about that. It was difficult for me to see the difference without having them on the same page, and including the images here seems to show that they are same graph. –  Peter Grill Apr 2 at 23:36

1 Answer 1

up vote 4 down vote accepted

I don't think there's anything wrong with tikz. It seems that you have forgotten a r in the formula (to interpret your angle as radians and not degrees):

\draw [domain=0:6.29,samples=500,smooth] plot (xy polar cs:angle=\x r,
       radius={\rad+\amp*cos(\n*\x r+sin(\n*\x r+\myphi) r+\myphi)});

It is precisely the last r appearing on the second line.

result

share|improve this answer
    
That solved it all. Thanks a lot. –  eiterorm Apr 3 at 0: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.