SHARE
TWEET

Sampling Code

ellenlee218 Nov 1st, 2016 (edited) 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (*Interactive code below for sampling*)
  2. Manipulate[
  3.  points = Table[{x, Sin[x]}, {x, 0, 20 Pi, sample}];
  4.  Show[
  5.   Plot[Sin[x],
  6.    {x, 0, 20 Pi},
  7.    Epilog -> {Red, PointSize -> 0.02, Point[points]},
  8.    PlotStyle -> Gray
  9.    ],
  10.   ListLinePlot[points, PlotStyle -> Red]
  11.   ], {sample, 0.1, 2 Pi}
  12.  ]
  13.  
  14. (*Code for the row of sampling error examples*)
  15. points1 = Table[{x, Sin[x]}, {x, 0, 20 Pi, 0.25}];
  16. points2 = Table[{x, Sin[x]}, {x, 0, 20 Pi, 2.95}];
  17. points3 = Table[{x, Sin[x]}, {x, 0, 20 Pi, 2 Pi}];
  18. GraphicsRow[{
  19.   Show[Plot[Sin[x], {x, 0, 20 Pi},
  20.     Epilog -> {Red, PointSize -> 0.02, Point[points1]},
  21.     PlotStyle -> Gray],
  22.    ListLinePlot[points1, PlotStyle -> Red]
  23.    ],
  24.   Show[Plot[Sin[x], {x, 0, 20 Pi},
  25.     Epilog -> {Red, PointSize -> 0.02, Point[points2]},
  26.     PlotStyle -> Gray],
  27.    ListLinePlot[points2, PlotStyle -> Red]
  28.    ],
  29.   Show[Plot[Sin[x], {x, 0, 20 Pi},
  30.     Epilog -> {Red, PointSize -> 0.02, Point[points3]},
  31.     PlotStyle -> Gray],
  32.    ListLinePlot[points3, PlotStyle -> Red]
  33.    ]
  34.   }, ImageSize -> 1000]
RAW Paste Data
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top