这是我的代码,我尝试将样本从 90 更改为 130,但没有成功。
\begin{tikzpicture}[scale=0.8]
\begin{axis}
[xlabel=$t$,ylabel=$x(t)$,xmin=-5,xmax=5,ymin=-2,ymax=2,grid=major,grid style={solid}]
\addplot[roza,line width=1pt,smooth] expression{(sin(90*x))+0.5};
\addplot[domain=-5:5,blue,samples=126,line width=0.7pt] expression{sin(90*x)+0.4*rand};
\addplot[roza,line width=1pt, smooth]expression{(sin(90*x))-0.5};
\end{axis}
\end{tikzpicture}
看起来是这样的:
答案1
发布图像的复制版如下。
从代码中可以看出,所采用的方法是绘制从原始图像中提取的数据点。因此,它更像是一种再现随机数据序列的噱头,而不是它应该有的样子(我们永远不会知道吗?)。但是,正如我一开始所说的,这是为了再生产(即副本)。
滚动到 MWE 末尾查看相关部分。
\documentclass[]{article}
\begin{filecontents}{rand.dat}
-4.98603821481 -1.15447154472
-4.91715550067 -1.31707317073
-4.82165277349 -0.634146341463
-4.68182909677 -1.20325203252
-4.58536585366 -0.634146341463
-4.48053240026 -1.05691056911
-4.38626462214 -0.227642276423
-4.28101951906 -0.69918699187
-4.18057699564 -0.60162601626
-3.98284792975 -0.0325203252033
-3.92055161058 0.585365853659
-3.78292339885 0.276422764228
-3.68124592638 0.227642276423
-3.61840074097 0.780487804878
-3.51946759974 1.05691056911
-3.41833899352 1.07317073171
-3.31309389043 0.60162601626
-3.21800281294 1.33333333333
-3.08353058214 1.39837398374
-3.01176632019 0.894308943089
-2.90953998148 0.780487804878
-2.77575383349 0.926829268293
-2.67503687695 0.991869918699
-2.57171280574 0.747967479675
-2.50420225721 0.747967479675
-2.37110219203 0.975609756098
-2.2971424651 0.211382113821
-2.196288292 0.260162601626
-2.09447360296 0.19512195122
-1.85201193784 -0.536585365854
-1.78724572056 -0.211382113821
-1.65044080821 -0.422764227642
-1.57799046345 -1.0081300813
-1.4451648314 -0.747967479675
-1.34335014236 -0.813008130081
-1.17086892388 -1.25203252033
-1.0713869164 -1.0406504065
-0.933484271552 -1.38211382114
-0.866385372714 -1.33333333333
-0.769922129601 -0.764227642276
-0.632431134438 -1.05691056911
-0.470241158108 -0.276422764228
-0.334122328565 -0.406504065041
-0.168639154746 -0.0162601626016
-0.0340297073857 0.0325203252033
0.0363623889403 -0.308943089431
0.168639154746 0.0162601626016
0.231347123598 0.585365853659
0.365133271586 0.731707317073
0.466536310933 0.715447154472
0.566567184659 0.861788617886
0.637233714109 0.487804878049
0.732324791602 1.21951219512
0.872285684882 0.634146341463
1.03475009434 1.38211382114
1.13944633117 0.975609756098
1.27336969572 1.10569105691
1.34595725704 0.50406504065
1.47905732222 0.731707317073
1.58100922781 0.650406504065
1.65044080821 0.422764227642
1.78367808995 0.634146341463
1.88604164523 0.50406504065
1.9598641556 -0.243902439024
2.09392473672 -0.130081300813
2.19766045762 -0.422764227642
2.29851463072 -0.373983739837
2.3997804535 -0.373983739837
2.47181914857 -0.910569105691
2.60409591438 -0.585365853659
2.70440122123 -0.471544715447
2.77753764879 -1.13821138211
2.87523584097 -0.715447154472
2.97801104593 -0.894308943089
3.07913965216 -0.878048780488
3.17848444307 -0.650406504065
3.28043634867 -0.731707317073
3.38376041988 -0.975609756098
3.51878151693 -0.975609756098
3.58519433296 -0.845528455285
3.6808342767 -0.178861788618
3.78621659634 -0.666666666667
3.95211141985 -0.325203252033
4.08342766972 0.113821138211
4.18551679188 0.0162601626016
4.28225446811 0.552845528455
4.38502967308 0.373983739837
4.51922747076 0.471544715447
4.61816061199 0.747967479675
4.72011251758 0.666666666667
4.78254605331 1.26829268293
4.91701828411 1.33333333333
4.98741038043 0.991869918699
\end{filecontents}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\centering
\begin{tikzpicture}
\begin{axis}[%
xlabel=$t$,
ylabel=$x(t)$,
xmin=-5,
xmax=5,
ymin=-2,
ymax=2,
grid=major,
grid style={solid},
samples=75
]
\addplot[red,line width=1pt,smooth] expression{(sin(90*x))+0.5};
\addplot[red,line width=1pt, smooth]expression{(sin(90*x))-0.5};
\addplot[blue,line width=0.7pt] table {rand.dat};
\end{axis}
\end{tikzpicture}
\end{document}