我使用这个功能:
\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}
我需要评估该\x
参数。如何打印它的值?在日志文件中也可以
雷纳托
答案1
要打印正在使用的所有点draw...plot
,您可以:
\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}
(继续……)
如果希望在日志文件中输出,可以添加(例如,在 par 之后)
\wlog{x is \x\space and the function \pgfmathresult}
你的.log
文件中将包含以下内容:
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
奇怪的是\space
,请参阅使用 \write 命令后留空格
显然,拥有它仅有的在日志文件中,使用循环:
\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
您的问题中没有提供太多信息,所以我只是使用了一些虚拟数字……
\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}