2

I use this function:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}

    \begin{document}
        \newcommand{\xmax}{14}
        \newcommand{\fmin}{(pi/3)}
        \newcommand{\fmax}{(2*pi)}
    \begin{tikzpicture}
    [domain=\xmax:0, samples=500]


    % The following line uses linear frequency increase
    %\draw[ultra thick, red] plot (\x, {sin(deg((\fmin+\x*((\fmax-\fmin))/\xmax)*\x))} );
    % The following line uses exponential frequency increase
    \draw[ultra thick, red] plot (\x, {sin(deg(exp(ln(\fmin)+\x/\xmax*(ln(\fmax)-ln(\fmin)))*\x))} );
    \end{tikzpicture}
    \end{document}

I need to evaluate the \x parameter. How can I print it's value? also on log file is ok

Renato

4

To print all the points that the draw...plot is using, you can:

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}

\begin{document}
\newcommand{\xmax}{14}
\newcommand{\fmin}{(pi/3)}
\newcommand{\fmax}{(2*pi)}
\begin{tikzpicture}
    [domain=\xmax:0, samples=500]
    \draw[ultra thick, red] plot (\x, {sin(deg(exp(ln(\fmin)+\x/\xmax*(ln(\fmax)-ln(\fmin)))*\x))} );
\end{tikzpicture}

\pgfmathsetmacro{\step}{\xmax/500}
\foreach \x in {0,\step,...,\xmax} {
    \x, \qquad 
    \pgfmathparse{sin(deg(exp(ln(\fmin)+\x/\xmax*(ln(\fmax)-ln(\fmin)))*\x))}\pgfmathresult
    \par
}

\end{document}

output

(continuing...)

If you want the output on the log file, you can add (after the par, for example)

 \wlog{x is \x\space and the function \pgfmathresult} 

and you'll have in your .log file:

x is 0 and the function 0.0
x is 0.028 and the function 0.02939
x is 0.056 and the function 0.05899
x is 0.084 and the function 0.08878
x is 0.112 and the function 0.11867

For the strange \space, see Space after command with \write

Clearly, to have it only on the log file, use as the loop:

\foreach \x in {0,\step,...,\xmax} { 
        \pgfmathparse{sin(deg(exp(ln(\fmin)+\x/\xmax*(ln(\fmax)-ln(\fmin)))*\x))}
        \wlog{x is \x\space and the function \pgfmathresult} 
    }
2

You don't give us much information in your question, so I'm just using some dummy numbers....

\documentclass{article}

\usepackage{tikz}


\begin{document}

\def\x{0.5}
\def\xmax{1}
\def\fmin{1}
\def\fmax{5}


\pgfmathparse{sin(deg(exp(ln(\fmin)+\x/\xmax*(ln(\fmax)-ln(\fmin)))*\x))}\pgfmathresult


\end{document}

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.