Sampling a Digital Signal

Manipulate[
If[k>50 L,k=50 L];
Grid[
{
{ListPlot[tmp,Filling -> Axis,PlotMarkers->Automatic,ImagePadding -> 20,ImageSize -> {400,200}]},{ListPlot[If[sampler == "up",f[L],f1[L]],Filling -> Axis,PlotRange -> {{0,k},{-1,1}},PlotMarkers->Automatic,ImagePadding -> 20,ImageSize -> {400,200}]}
}
],
{{L,2,"sampling by integer factor L"},2,10,1,Appearance->"Labeled"},
{{k,50,"bottom plot range"},1,50 L,1,Appearance->"Labeled"},
{{sampler,"up"},{"up","down"}},
TrackedSymbols->{L,k,sampler},
Initialization :> {
tmp = Table[Sin[x],{x,0, 720 Degree, 15 Degree}]//N;
f[L1_]:=Flatten[Riffle[tmp,{ConstantArray[0,L1-1]}]];
f1[L2_] := tmp[[1;; ;;L2]];
}
]

CAPTION

Sampling data is the first step in the signal processing of wave forms coming from radar, submarine detection, earthquakes, seismic oil exploration, etc. Up-sampling and down-sampling are the basic operations in multirate discrete-time systems.

The bottom part of the figure shows up-sampling and down-sampling by an integer factor L > 1 of the signal at the top. For the up-sampling process, L-1 equidistant zero-valued samples are inserted by the up-sampler between each consecutive sample of the input sequence x(n).

Conversely, the down-sampling operation on the input sequence consists of keeping every (L^th) sample of x(n)  and removing the others.

DETAILS

The up-sampled sequence y(n) is developed according to the input sequence x(n):

y(n) = {({{x(n/L), n=0,±L,±2L,…,}, {0, otherwise}})

The sampling rate of y(n) is L times larger than that of the original sequence x(n).

The down-sampled sequence y(n) is developed according to the input sequence x(n):

y(n) = x(n L)

Here the sampling rate of y(n) is ((((1/L)))^th) that of the original sequence x(n).

S. Mitra, Digital Signal Processing, 3rd ed., New York: McGraw-Hill, 2005.

THIS NOTEBOOK IS THE SOURCE CODE FROM

"Sampling a Digital Signal" from the Wolfram Demonstrations Project
 http://demonstrations.wolfram.com/SamplingADigitalSignal/

Contributed by: Siva Perla

A full-function Wolfram Mathematica system (Version 6 or higher) is required to edit this notebook.
GET WOLFRAM MATHEMATICA »

© Wolfram Demonstrations Project & Contributors   |   Terms of Use   |   Make a new version of this Demonstration »