# Tag Info

5

Your grouping is not correct and implicit multiplication is not implemented yet. \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.10} \begin{document}% \begin{tikzpicture} \begin{axis}[ axis lines = left, xlabel = Number of Elements, ylabel = {$\mathrm{Combinations}=\frac{(n)!}{(n-r)!(r!)}$}, ] %Axis \addplot [ domain=2:10, ...

4

No but there must be a badge for the most intertwined question though. Why you ever need a recursion for this I don't know :) If I remember correctly, you are, knowingly or not, hacking into an intermediate step of the syntax for multidimensional arrays, example, \pgfmathparse{\A[0][0]} renders the \A[0], {9}{8}{7} before it moves to the next bracket. ...

4

\pgfmathifthenelse is the standalone version that writes the result to \pgfmathresult, setting macro needs the inline math function evaluated such as \pgfmathsetmacro{\newVar}{ifthenelse(\oldVar==0,(\x/2),\x)} or shorter \pgfmathsetmacro{\newVar}{(\oldVar==0?(\x/2):\x)}.

6


1

Consider the following MWE: \documentclass{article} \setlength{\parindent}{0pt} \newcommand{\h}[2]{% \begingroup% \edef\x{#1} \global\edef#2{#1} \endgroup} \begin{document} \def\x{0} \def\y{1} \h{2}{\y} x=\x\newline y=\y\newline \end{document} If you remove the \begingroup \endgroup, you will get x=2, y=2. If you remove the \global you will get ...

6

Here, I complete the excellent cmhuges's answer to show how to use the declare function key: \documentclass[tikz,border=3mm]{standalone} \begin{document} \begin{tikzpicture} \tikzset{declare function={ data(\a,\b,\x)=or(\x<\a, \x>\b)?1:0; }} \draw [red,thick] (0,0) -- plot [domain= 0:80,samples=160,smooth] (\x,{data(20,40,\x)}); ...

7

Your pgfmath is ok, but you need to use \draw [red, thick] plot [domain= 0:80, samples=160, smooth] (\x,{data(20,40)}); Note the {} in (\x,{data(20,40)}). Here's a complete MWE: % arara: pdflatex \documentclass[tikz,border=3mm]{standalone} \begin{document} \pgfmathdeclarefunction{data}{2}{% \pgfmathifthenelse{(or(\x<#1, \x>#2))}{1}{0}% } ...

Top 50 recent answers are included