21
Sampling and Signal Reconstruction Lab 10

Sampling and Signal Reconstructionperrins/class/F14_360/lab/... · 2014-11-05 · Nyquist in terms of Reconstruction If the sampling rate, 𝑓𝑠, is not large enough (larger than

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Sampling and Signal Reconstructionperrins/class/F14_360/lab/... · 2014-11-05 · Nyquist in terms of Reconstruction If the sampling rate, 𝑓𝑠, is not large enough (larger than

Sampling and Signal Reconstruction

Lab 10

Page 2: Sampling and Signal Reconstructionperrins/class/F14_360/lab/... · 2014-11-05 · Nyquist in terms of Reconstruction If the sampling rate, 𝑓𝑠, is not large enough (larger than

Continuous Signals 𝑥(𝑡)

Page 3: Sampling and Signal Reconstructionperrins/class/F14_360/lab/... · 2014-11-05 · Nyquist in terms of Reconstruction If the sampling rate, 𝑓𝑠, is not large enough (larger than

Sampling 𝑋 𝑛𝑇𝑠 → 𝑥 𝑛

Page 4: Sampling and Signal Reconstructionperrins/class/F14_360/lab/... · 2014-11-05 · Nyquist in terms of Reconstruction If the sampling rate, 𝑓𝑠, is not large enough (larger than

Nyquist Sampling Theorem

Remember this result? It says that when you sample a signal every 𝑇𝑠 in the time domain the frequency domain is periodic (it repeats every 𝑓𝑠). The “copies” that occur every multiple of ±𝑓𝑠 are called aliases.

∴ 𝑥 𝑡 𝛿𝑇𝑠 ℱ

1

𝑇𝑠𝛿𝑓𝑠 ∗ 𝑋 𝑓

Page 5: Sampling and Signal Reconstructionperrins/class/F14_360/lab/... · 2014-11-05 · Nyquist in terms of Reconstruction If the sampling rate, 𝑓𝑠, is not large enough (larger than

Reconstruction

In some instances we would like to reconstruct the original signal.

This may not yield a signal that even remotely resembles the original signal!

𝑥 𝑛 → 𝑋 𝑛𝑇𝑠

Page 6: Sampling and Signal Reconstructionperrins/class/F14_360/lab/... · 2014-11-05 · Nyquist in terms of Reconstruction If the sampling rate, 𝑓𝑠, is not large enough (larger than

Nyquist in terms of Reconstruction

If the sampling rate, 𝑓𝑠, is not large enough (larger than twice the bandlimit, 𝑓𝑚) then the aliases will overlap: an effect known as Aliasing.

If and only if a signal is sampled at this frequency (or above) can the original signal be reconstructed in the time-domain.

𝑓𝑠 > 2𝑓𝑚

Page 7: Sampling and Signal Reconstructionperrins/class/F14_360/lab/... · 2014-11-05 · Nyquist in terms of Reconstruction If the sampling rate, 𝑓𝑠, is not large enough (larger than

Reconstruction Methods

Page 8: Sampling and Signal Reconstructionperrins/class/F14_360/lab/... · 2014-11-05 · Nyquist in terms of Reconstruction If the sampling rate, 𝑓𝑠, is not large enough (larger than

Zeroth-Order Interpolation

Zeroth-Order Interpolation means we accept the value on the discrete sample for the time window that the sample was taken from originally.

This is basically just approximating each time window with a constant.

Page 9: Sampling and Signal Reconstructionperrins/class/F14_360/lab/... · 2014-11-05 · Nyquist in terms of Reconstruction If the sampling rate, 𝑓𝑠, is not large enough (larger than

Zeroth-Order Code clc,clear,close all

deltat=0.01; %time window

n=0:deltat:1; %time index

N=length(n); %number of sampled points

x=cos(20*pi*n); %signal

ta=0:0.001:1; %reconstruction time

y1=[];

for i=1:N-1

y1=[y1 ones(1,10)*x(i)];

end

y1=[y1 x(end)]; %it was one element too short

Page 10: Sampling and Signal Reconstructionperrins/class/F14_360/lab/... · 2014-11-05 · Nyquist in terms of Reconstruction If the sampling rate, 𝑓𝑠, is not large enough (larger than

Zeroth- Order Interpolation

Page 11: Sampling and Signal Reconstructionperrins/class/F14_360/lab/... · 2014-11-05 · Nyquist in terms of Reconstruction If the sampling rate, 𝑓𝑠, is not large enough (larger than

Zeroth-Order Code clc,clear,close all

deltat=0.01; %time window

n=0:deltat:1; %time index

N=length(n); %number of sampled points

x=cos(20*pi*n); %signal

ta=0:0.001:1; %reconstruction time

y1=[];

for i=1:N-1

y1=[y1 ones(1,10)*x(i)];

end

y1=[y1 x(end)];

y1=[y1(5:end) x(1:4)];

Phase correction, this works because the signal is periodic!

Page 12: Sampling and Signal Reconstructionperrins/class/F14_360/lab/... · 2014-11-05 · Nyquist in terms of Reconstruction If the sampling rate, 𝑓𝑠, is not large enough (larger than

Zeroth-Order Interpolation – With phase correction

Page 13: Sampling and Signal Reconstructionperrins/class/F14_360/lab/... · 2014-11-05 · Nyquist in terms of Reconstruction If the sampling rate, 𝑓𝑠, is not large enough (larger than

rectpuls()

Matlab has a function which does this zeroth-order interpolation. It’s called rectpuls().

This function operates by multiplying each sampled amplitude by a shifted and compressed rectangle pulse signal.

Page 14: Sampling and Signal Reconstructionperrins/class/F14_360/lab/... · 2014-11-05 · Nyquist in terms of Reconstruction If the sampling rate, 𝑓𝑠, is not large enough (larger than

Code using rectplus() Ts=0.01; %time window

n=0:Ts:1; %time index

Fs=1/Ts; %sample rate

N=length(n); %number of sampled points

x=cos(20*pi*n); %original signal

ta=0:0.001:1; %reconstruction time

y=zeros(N,length(ta)); %reconstruction vector

for i=1:N

y(i,:)=x(i)*rectpuls(Fs*ta-i+1);

end

plot(ta,sum(y)) compression

time shift

Page 15: Sampling and Signal Reconstructionperrins/class/F14_360/lab/... · 2014-11-05 · Nyquist in terms of Reconstruction If the sampling rate, 𝑓𝑠, is not large enough (larger than

Same result as Zeroth-Order Approximation!

Page 16: Sampling and Signal Reconstructionperrins/class/F14_360/lab/... · 2014-11-05 · Nyquist in terms of Reconstruction If the sampling rate, 𝑓𝑠, is not large enough (larger than

Matrix Operations instead of For-Loop

Ts=0.01; %time window

n=0:Ts:1; %time index

Fs=1/Ts; %sample rate

N=length(n); %number of sampled points

x=cos(20*pi*n); %original signal

ta=0:0.001:1; %reconstruction time

Na=length(ta); %reconstruction length

y=x*rectpuls(Fs*(ones(N,1)*ta-n'*ones(1,Na)));

Page 17: Sampling and Signal Reconstructionperrins/class/F14_360/lab/... · 2014-11-05 · Nyquist in terms of Reconstruction If the sampling rate, 𝑓𝑠, is not large enough (larger than

Left for your report

Reconstruct the signal using tripuls() and sinc().

Page 18: Sampling and Signal Reconstructionperrins/class/F14_360/lab/... · 2014-11-05 · Nyquist in terms of Reconstruction If the sampling rate, 𝑓𝑠, is not large enough (larger than

Higher-Order Methods

Page 19: Sampling and Signal Reconstructionperrins/class/F14_360/lab/... · 2014-11-05 · Nyquist in terms of Reconstruction If the sampling rate, 𝑓𝑠, is not large enough (larger than

Cubic Spline Interpolation

There is a higher order polynomial interpolation known as the spline method.

This approximation is used a lot as it results in a very smooth curve.

𝑌𝑖 𝑡 = 𝑎𝑖 + 𝑏𝑖𝑡 + 𝑐𝑖𝑡2 + 𝑑𝑖𝑡

3

Page 20: Sampling and Signal Reconstructionperrins/class/F14_360/lab/... · 2014-11-05 · Nyquist in terms of Reconstruction If the sampling rate, 𝑓𝑠, is not large enough (larger than

Spline Code

Ts=0.01; %time window

n=0:Ts:1; %time index

x=cos(20*pi*n); %sampled signal

ta=0:0.001:1; %reconstruction time

y=spline(n,x,ta);

Sampled Amplitudes

Reconstruction Indexes

Sampled Indexes

Page 21: Sampling and Signal Reconstructionperrins/class/F14_360/lab/... · 2014-11-05 · Nyquist in terms of Reconstruction If the sampling rate, 𝑓𝑠, is not large enough (larger than

Cubic Spline Interpolation

Why is there only one?