Main Content

Obtain Signal Phases Using Downsampling

This example shows how to use downsample to obtain the phases of a signal. Downsampling a signal by M can produce M unique phases. For example, if you have a discrete-time signal, x, with x(0),x(1),x(2),x(3),...,x(n-1), the M phases of x are x(nM+k) with k=0,1,...,M-1.

The M signals are referred to as the polyphase components of x.

Create a white noise vector and obtain the 3 polyphase components associated with downsampling by 3.

Reset the random number generator to the default settings to produce a repeatable result. Generate a white noise random vector and obtain the 3 polyphase components associated with downsampling by 3.

rng("default")
x = randn(36,1);
x0 = downsample(x,3,0);
x1 = downsample(x,3,1);
x2 = downsample(x,3,2);

The polyphase components have length equal to 1/3 the original signal.

Upsample the polyphase components by 3 using upsample.

y0 = upsample(x0,3,0);
y1 = upsample(x1,3,1);
y2 = upsample(x2,3,2);

Plot the result.

tiledlayout("vertical")
nexttile
stem(x,Marker="none")
title("Original Signal")
ylim([-4 4])

nexttile
stem(y0,Marker="none")
ylabel("Phase 0")
ylim([-4 4])

nexttile
stem(y1,Marker="none")
ylabel("Phase 1")
ylim([-4 4])

nexttile
stem(y2,Marker="none")
ylabel("Phase 2")
ylim([-4 4])

Figure contains 4 axes objects. Axes object 1 with title Original Signal contains an object of type stem. Axes object 2 with ylabel Phase 0 contains an object of type stem. Axes object 3 with ylabel Phase 1 contains an object of type stem. Axes object 4 with ylabel Phase 2 contains an object of type stem.

If you sum the upsampled polyphase components you obtain the original signal.

Create a discrete-time sinusoid and obtain the 2 polyphase components associated with downsampling by 2.

Create a discrete-time sine wave with an angular frequency of π/4 rad/sample. Add a DC offset of 2 to the sine wave to help with visualization of the polyphase components. Downsample the sine wave by 2 to obtain the even and odd polyphase components.

n = 0:127;
x = 2+cos(pi/4*n);
x0 = downsample(x,2,0);
x1 = downsample(x,2,1);

Upsample the two polyphase components.

y0 = upsample(x0,2,0);
y1 = upsample(x1,2,1);

Plot the upsampled polyphase components along with the original signal for comparison.

tiledlayout("vertical")
nexttile
stem(x,Marker="none")
ylim([0.5 3.5])
title("Original Signal")
nexttile
stem(y0,Marker="none")
ylim([0.5 3.5])
ylabel("Phase 0")
nexttile
stem(y1,Marker="none")
ylim([0.5 3.5])
ylabel("Phase 1")

Figure contains 3 axes objects. Axes object 1 with title Original Signal contains an object of type stem. Axes object 2 with ylabel Phase 0 contains an object of type stem. Axes object 3 with ylabel Phase 1 contains an object of type stem.

If you sum the two upsampled polyphase components (Phase 0 and Phase 1), you obtain the original sine wave.

See Also

|