如何绘制以下函数?

如何绘制以下函数?

我想绘制以下代码,但尝试后发现无法工作。唯一绘制的图表是第一个。

    \begin{axis}[
     xmin = 0, xmax = 0.0009,
     ymin = -1, ymax = 1,
     xtick distance = 0.0001,
    ytick distance = 0.25,
    grid = both,
    minor tick num = 1,
    major grid style = {lightgray},
    minor grid style = {lightgray!25},
    width = \textwidth,
    height = 0.5\textwidth]
        \addplot[
        domain = 0:0.0009,
        samples = 300,
        smooth,
        thick,
        blue,
                ] {(0.6)* (sin(deg(2*pi*20000*x - 83.1))};
                  \addplot[
         domain = 0:0.0007,
         samples = 200,
         smooth,
         thick,
         red,
                 ] {-(0.6)* (sin(deg(- 83.1))*(e^-(x/659*100*10^-9))+(0.6)* (sin(deg(2*pi*20000*x - 83.1))};
                 
        \addplot[
        domain = 0:0.0009,
        samples = 100,
        smooth,
        thick,
        orange,
                ] {-0.6*e^{-x/65.9*10^-6}};
    \end{axis}
\end{tikzpicture}```

答案1

欢迎来到 TeX.SX!您应该确保在公式中填写所有括号。此外,在公式中,()应使用圆括号(圆括号),而不是花括号{}

\documentclass[border=1mm]{standalone}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
    xmin = 0, xmax = 0.0009,
    ymin = -1, ymax = 1,
    xtick distance = 0.0001,
    ytick distance = 0.25,
    grid = both,
    minor tick num = 1,
    major grid style = {lightgray},
    minor grid style = {lightgray!25},
    width = \textwidth,
    height = 0.5\textwidth]
    \addplot[
        domain = 0:0.0009,
        samples = 300,
        smooth,
        thick,
        blue,
        ] {(0.6)*(sin(deg(2*pi*20000*x-83.1)))}; % one closing bracket was missing
        % probably better: {0.6*sin(deg(2*pi*20000*x-83.1))}
    \addplot[
        domain = 0:0.0007,
        samples = 200,
        smooth,
        thick,
        red,
        ] {-(0.6)*(sin(deg(-83.1))*(e^-(x/659*100*10^-9))) + (0.6)*(sin(deg(2*pi*20000*x-83.1)))}; % two closing brackets were missing
        % probably better and what you mean: {-0.6*sin(-83.1)*exp(-x/(659*100e-9)) + 0.6*sin(deg(2*pi*20000*x-83.1))}
    \addplot[
        domain = 0:0.0009,
        samples = 100,
        smooth,
        thick,
        orange,
        ] {-0.6*e^(-x/65.9*10^-6)}; % curly brackets were used
        % probably better and what you mean: {-0.6*exp(-x/(65.9e-6)}
\end{axis}
\end{tikzpicture}

\end{document}

其结果是:

在此处输入图片描述

在上面的代码中,我在注释中对三个公式进行了改进。我还对第二个和第三个公式做了一些修改,因为我认为你可能希望它们是这样。当你使用这些改进和修改的函数编译代码时,你将得到以下结果:

在此处输入图片描述

相关内容