OldCourses downsampling_example

downsampling_example

downsampling_example

body {
background-color: white;
margin:10px;
}

h1 {
color: #990000;
font-size: x-large;
}

h2 {
color: #990000;
font-size: medium;
}

/* Make the text shrink to fit narrow windows, but not stretch too far in
wide windows. */
p,h1,h2,div.content div {
max-width: 600px;
/* Hack for IE6 */
width: auto !important; width: 600px;
}

pre.codeinput {
background: #EEEEEE;
padding: 10px;
}
@media print {
pre.codeinput {word-wrap:break-word; width:100%;}
}

span.keyword {color: #0000FF}
span.comment {color: #228B22}
span.string {color: #A020F0}
span.untermstring {color: #B20000}
span.syscmd {color: #B28C00}

pre.codeoutput {
color: #666666;
padding: 10px;
}

pre.error {
color: red;
}

p.footer {
text-align: right;
font-size: xx-small;
font-weight: lighter;
font-style: italic;
color: gray;
}

Contents

% downsampling_example.m
%


w = linspace(-4*pi, 4*pi, 2000);

Original DTFT, bandlimited triangle

% triangle function between -pi/2 and pi/2
Xnp = @(z) max(1-2*abs(z)/pi, 0);
% 2pi perdiodic version
X = @(z) Xnp(mod(z+pi,2*pi)-pi);

% plot the original DTFT
ticvec =  [-4 -3 -2 -1 -.5 0 0.5 1 2 3 4];
plot(w/pi, X(w));
set(gca, 'xtick', ticvec);
xlabel('omega in units of pi')

Downsampled DTFT, bandlimited trigangle, separate parts

this plots the first term in black, the second in red

plot(w/pi, 1/2*X(w/2), 'k', w/pi, 1/2*X(w/2 - pi), 'r');
set(gca, 'xtick', ticvec);
xlabel('omega in units of pi')

Downsampled DTFT, bandlimited trigangle, sum

Xd = @(z) 1/2*(X(z/2) + X(z/2 - pi));
% this plots the sum of the black and the red
plot(w/pi, Xd(w))
set(gca, 'xtick', ticvec);
xlabel('omega in units of pi')

Original DTFT, non-bandlimited triangle

% triangle function between -pi and pi
Xnp = @(z) max(1-abs(z)/pi, 0);
% 2pi perdiodic version
X = @(z) Xnp(mod(z+pi,2*pi)-pi);

% plot the original DTFT
ticvec =  [-4 -3 -2 -1 -.5 0 0.5 1 2 3 4];
plot(w/pi, X(w));
set(gca, 'xtick', ticvec);
xlabel('omega in units of pi')

Downsampled DTFT, non-bandlimited trigangle, separate parts

this plots the first term in black, the second in red

plot(w/pi, 1/2*X(w/2), 'k', w/pi, 1/2*X(w/2 - pi), 'r');
set(gca, 'xtick', ticvec);
xlabel('omega in units of pi')

Downsampled DTFT, non-bandlimited trigangle, sum

Xd = @(z) 1/2*(X(z/2) + X(z/2 - pi));
% this plots the sum of the black and the red
plot(w/pi, Xd(w))
set(gca, 'xtick', ticvec, 'ylim', [0 1]);
xlabel('omega in units of pi')