## Ideal Sampling and Reconstruction

### sampling theorem

If $$f(t)$$ is a band-limited signal with a bandwidth of $$\omega_{m}$$, the sampled spectrum $$F_{s}(\omega)$$ of $$f(t)$$ is the spectrum of $$f$$. The spectrum $$F(\omega)$$ is periodically extended on the frequency axis at intervals of the sampling frequency $$\omega_{s}$$. Thus, when $$\omega_{s} \geq \omega_{m}$$ frequency overlap does not occur; instead, it occurs when $$\omega_{s}<\omega_{m}$$.

### Model of Ideal Sampling

A continuous signal $$x(t)$$ is sampled by taking its amplitude values at given time-instants. These time-instants can be chosen arbitrary in time, but most common are equidistant sampling schemes. The process of sampling is modeled by multiplying the continuous signal with a series of Dirac impulses. This constitutes an idealized model since Dirac impulses cannot be realized in practice.

For equidistant sampling of a continuous signal $$x(t)$$ with sampling interval $$T$$, the sampled signal $$x_\text{s}(t)$$ reads

$$x_\text{s}(t) = \sum_{k = - \infty}{\infty} x(t) \cdot \delta(t - k T) = \sum_{k = - \infty}{\infty} x(k T) \cdot \delta(t - k T)$$

where the multiplication property of the Dirac impulse was used for the last equality. The sampled signal is composed from a series of equidistant Dirac impulse which are weighted by the amplitude values of the continuous signal taken at their time-instants.

The series of Dirac impulse is represented conveniently by the Dirac comb. Rewriting the sampled signal yields

$$x_\text{s}(t) = x(t) \cdot \frac{1}{T} {\bot !! \bot !! \bot} \left( \frac{t}{T} \right)$$

The process of sampling can be modeled by multipyling the continuous signal $$x(t)$$ with a Dirac comb. The samples $$x(k T)$$ for $$k \in \mathbb{Z}$$ of the continuous signal constitute the discrete (-time) signal $$x[k] := x(k T)$$. The question arises if and under which conditions the samples $$x[k]$$ fully represent the continuous signal and allow for a reconstruction of the analog signal. In order to investigate this, the spectrum of the sampled signal is derived.

### Reconstruction

#### Ideal Reconstruction deduction

The question arises if and under which conditions the continuous signal can be recovered from the sampled signal. Above consideration revealed that the spectrum $$X_\text{s}(j \omega)$$ of the sampled signal contains the unaltered spectrum of the continuous signal $$X(j \omega)$$ if $$\omega_\text{u} < \frac{\omega_\text{s}}{2}$$. Hence, the continuous signal can be reconstructed from the sampled signal by extracting the spectrum of the continuous signal from the spectrum of the sampled signal. This can be done by applying an ideal low-pass with cut-off frequency $$\omega_\text{c} = \frac{\omega_{s}}{2}$$. This is illustrated in the following

where the blue line represents the spectrum of the sampled signal and the red line the spectrum of the ideal low-pass. The transfer function $$H(j \omega)$$ of the low-pass reads

$$H(j \omega) = T \cdot \text{rect} \left( \frac{\omega}{\omega_\text{s}} \right)$$

Its impulse response $$h(t)$$ is yielded by inverse Fourier transform of the transfer function

$$h(t) = \text{sinc} \left( \frac{\pi t}{T} \right)$$

The reconstructed signal $$y(t)$$ is given by convolving the sampled signal $$x_\text{s}(t)$$ with the impulse response of the low-pass filter. This yields

\begin{align} y(t) &= x_\text{s}(t) * h(t) \ &= \left( \sum_{k = - \infty}{\infty} x(k T) \cdot \delta(t - k T) \right) * \text{sinc} \left( \frac{\pi t}{T} \right) \ &= \sum_{k = - \infty} {\infty} x(k T) \cdot \text{sinc} \left( \frac{\pi}{T} (t - k T) \right) \end{align}

where for the last equality the fact was exploited that $$x(k T)$$ is independent of the time $$t$$ for which the convolution is performed. The reconstructed signal is given by a weighted superposition of shifted sinc functions. Their weights are given by the samples $$x(k T)$$ of the continuous signal. The reconstruction is illustrated in the following figure

The black boxes show the samples $$x(k T)$$ of the continuous signal, the blue line the reconstructed signal $$y(t)$$, the gray lines the weighted sinc functions. The sinc function for $$k = 0$$ is highlighted in red. The amplitudes $$x(k T)$$ at the sampled positions are reconstructed perfectly since

$$\text{sinc} ( \frac{\pi}{T} (t - k T) ) = \begin{cases} \text{sinc}(0) = 1 & \text{for } t=k T \ \text{sinc}(n \pi) = 0 & \text{for } t=(k+n) T \quad , n \in \mathbb{Z} \notin {0} \end{cases}$$

The amplitude values in between the sampling positions $$t = k T$$ are given by superimposing the shifted sinc functions. The process of computing values in between given sampling points is termed interpolation. The reconstruction of the sampled signal is performed by interpolating the discrete amplitude values $$x(k T)$$. The sinc function is the optimal interpolator for band-limited signals.

#### Implementation

After the sampling we get the function $$f_{s}(t)$$ passing the low-pass filter $$h(t)$$ so,we get the reconstructed func $$f(t),$$ which is:
$$f(t)=f_{s}(t) * h(t)$$
which we can deduct $$\quad f_{s}(t)=f(t) \sum_{-\infty}^{\infty} \delta\left(t-n T_{s}\right)=\sum_{-\infty}^{\infty} f\left(n T_{s}\right) \delta\left(t-n T_{s}\right)$$
$$h(t)=T_{s} \frac{\omega_{c}}{\pi} S a\left(\omega_{c} t\right)$$
Therefore,
\begin{aligned} f(t) &=f_{s}(t) * h(t)=\sum_{-\infty}{\infty} f\left(n T_{s}\right) \delta\left(t-n T_{s}\right) * T_{s} \frac{\omega_{c}}{\pi} S a\left(\omega_{c} t\right) \ &=T_{s} \frac{\omega_{c}}{\pi} \sum_{-\infty} {\infty} f\left(n T_{s}\right) \operatorname{Sa}\left[\omega_{c}\left(t-n T_{s}\right)\right] \end{aligned}
The equation shows that, the equation can be reconstructed as infinity continuous series.

We select the signal $$f(t)=S a(t)$$ as the sampled signal, which, when sampled at $$\omega_{s}=2 \omega_{m}$$, is called pro
Boundary sampling. We take the ideal low-pass cutoff frequency $$\omega_{c}=\omega_{m}$$ The following program implements the following for the signal $$f(t)=S a(t)$$
Sampling and reconstruction from that sampling signal recovery $$S a(t):$$

wm= 1;	%信号带宽
wc=wm;	%滤波器截止频率
Ts=pi/wm; 	%采样间隔
ws=2*pi/Ts;	%采样角频率.
n=-100:100;	%时域采样电数
nTs=n*Ts 	%时域采样点
f=sinc(nTs/pi);
Dt=0.005;t=-15:Dt:15;
fa=f*Ts*wc/pi*sinc((wc/pi)*(ones(length(nTs),1)*t-nTs'*ones(1 ,length())); %信号重构
t1=-15:0.5:15;
f1 =sinc(t1/pi);
subplot(211);
stem(t1,fl);
xlabel(kTs');
ylabel(f(kTs);
title('sa(t)=sinc(t/pi)的临界采样信号');
subplot(212);
plot(t,fa)
xlabel(t);
ylabel(fa(t);
title('由sa(t)=sinc(t/pi)的临界采样信号重构sa(t)');
grid;


#### Aliasing Reason

So far the case was discussed when no overlaps occur in the spectrum of the sampled signal. Hence when the upper frequency limit $$\omega_\text{u}$$ of the real-valued low-pass signal is lower than $$\frac{\omega_\text{s}}{2}$$. Here a perfect reconstruction of the continuous signal $$x(t)$$ from its discrete counterpart $$x[k]$$ is possible. However when this condition is not met, the repetitions of the spectrum of the continuous signal overlap. This is illustrated in the following

In this case no perfect reconstruction of the continuous signal by low-pass filtering (interpolation) of the sampled signal is possible. The spectrum within the pass-band of the low-pass contains additional contributions from the repeated spectrum of the continuous signal. These contributions are known as aliasing. It becomes evident from above discussion of ideal reconstruction that the amplitude values are reconstructed correctly at the time-instants $$k T$$. However, in between these time-instants the reconstructed signal $$y(t)$$ differs from the sampled signal $$x(t)$$ if aliasing is present.

#### Implementation

wm=1;
wc=1.1 *wm;
Ts=0.7*pi/wm;
ws= 2*pi/Ts;
n=- 100:100;
nTs=n*Ts
f=sinc(nTs/pi);
Dt=0.005;t=- 15:Dt:15;
fa=f* Ts*wc/pi* sinc((wc/pi)*(ones(length(nTs),1 )*t-nTs'*ones( 1,length(t))));
error=abs(fa-sinc(t/pi)); %重构信号与原信号误差
t1=-15:0.5:15;
fl=sinc(t1/pi);
subplot(311);
stem(t1,fl);
xlabel('kTs');
ylabel('f(kTs)');
title('sa(t)=sinc(t/pi)的采样信号');
subplot(312);
plot(t,fa)
xlabel('t');
ylabel('fa(t)');
title('由sa(t)=sinc(t/pi)的过采样信号重构sa(t)');
grid;
subplot(313);
plot(t,error);
xlabel('t)');
ylabel('error()');
title('过采样信号与原信号的误差error(t)');


### summary

!credit: bachelors module Signals and Systems, Communications Engineering, Universität Rostock.[email protected].

The order of sampling and quantization can be exchanged under the assumption that both are memoryless processes. Only digital signals can be handled by digital signal or general purpose processors. The sampling of signals is discussed as a first step towards a digital signal.

## 三角函数的时频图和复频图

clear;clf;
syms t;
f=2;T=1/f;t0=0;
A=1;
%ft=A*sin(2*pi*f*t);
ft=A*cos(2*pi*f*t+pi/4);
subplot(2,2,[1,3]); fplot(ft,[0 3]);title("time domain" ); xlabel( 't(second)');ylabel( 'y(t)' );
w = 2*pi*f;N =10;
Fn = zeros(1,N);
Wn = zeros(1,N);
for k = 0:N-1
Fn(k+1) = 2*1/T*int(ft*exp(-1j*k*w*t),t, [t0, t0+T]);
Wn(k+1) = k*w;
end
subplot(2,2,2); stem(Wn/ (2*pi),abs(Fn));title('frequency_ _amplitude' ); xlabel('f(Hz)' );ylabel('Y');
subplot(2,2,4); stem(Wn/ (2*pi),angle(Fn)*180/pi);title(' frequency_ phase'); xlabel('f(Hz)' );ylabel('Y')


## 方波信号的时频图和复频图

clear;clf;
t=0:0.01:3;
f=2;T=1/f;t0=0;
A=1;
%ft=A*sin(2*pi*f*t);
ft=square(2*pi/T*t);
subplot(2,2,[1,3]); fplot(ft,[0 3]);title("time domain" ); xlabel( 't(second)');ylabel( 'y(t)' );
w = 2*pi*f;N =10;
Fn = zeros(1,N);
Wn = zeros(1,N);
for k = 0:N-1
[email protected](t) square(2*pi/T*t).*exp(-1j*k*w*t);
Fn(k+1) = 2/T*integral(fun,t0,t0+T);
Wn(k+1) = k*w;
end
subplot(2,2,2); stem(Wn/ (2*pi),abs(Fn));title('frequency_ _amplitude' ); xlabel('f(Hz)' );ylabel('Y');
subplot(2,2,4); stem(Wn/ (2*pi),angle(Fn)*180/pi);title(' frequency_ phase'); xlabel('f(Hz)' );ylabel('Y')


## 信号转换可以找到信号的特性

clear;clf;
Fs = 1000;
ts = 1/Fs;
N = 3000;
t = (0:N-1)*ts;
signal1 = 0.7*sin(2*pi*50*t)+sin(2*pi*120*t)+2*randn(size(t));
subplot(2,1,1);plot(t,signal1); title('time domain'); xlabel('t(second)');ylabel('y(t)');
Y = fft(signal1);
Y = abs(Y/N);
Y = Y(1:N/2+1);
Y(2:end) = 2*Y(2:end);
f = (0:N/2)*Fs/N;
subplot(2,1,2);plot(f,Y); title(' frequency domain' ); xlabel('f(Hz)');ylabel('Y');


## 方波是一种频域三角函数

t = -2:0.001:2;
N = input('N=');
a0 = 0.5;
f = a0*ones(1,length(t));
for n=1:2:N
f = f+cos(n*pi*t)*sinc(n/2);
end
plot(t,f);grid on;
title(['N=' num2str(N)]);
xlabel('t');ylabel('f(t)');
axis([-2,2,-0.2,1.2])


t = -2:0.001:2;
N = input('N=');
T1 = 2;
w1 = 2*pi/T1;
fun = @(t) t.^0;
a0 = 1/T1*integral(fun,-0.5,0.5);
f = a0;
an = zeros(1,N);
bn = zeros(1,N);
for i = 1:N
fun = @(t) (t.^0).*cos(i*w1.*t);
an(i) = 2/T1.*integral(fun,-0.5,0.5);
fun = @(t) (t.^0).*sin(i*w1.*t);
bn(i) = 2/T1.*integral(fun,-0.5,0.5);
f = f + an(i)*cos(i*w1.*t)+bn(i)*sin(i*w1.*t);
end
plot(t,f); grid on;
title(['N=' num2str(N)]);
axis([-2 2 -0.2 1.2]);


## A brief summary of why we have to learn S&S

Note:

1. The "齐次方程" and "齐次方程的通解“ is different.
2. An example why $$f(0_-)$$ is not 0 since $$f$$ is a causal system: before the impulse, is the state of $0_-$, the effect is the zero-state response. So regarding the physical meaning, they are different.

## Matlab intro

Matlab can't defer the zero-state or zero-input

## Defination

### Example

1. a 3-dim Euclid space $$R^{3} \vec{a}=(1,0,0) \vec{b}=(0,1,0)\vec{c}=(0,0,1)$$
2. define n-dim space $$V$$
$$X(t)=\Sigma^{\inf}_{k=-\inf}e^{jk\omega _{0}t}$$
$$S=\{x(t)|x(t)=x(t+t_{0})\forall \}$$ $$T_{0}=\frac{2\pi}{\omega_{0}}$$
comment: <2$$T_{0}$$
$$B=\{\phi_{k}t|\phi_{k}(t)=e^{jkw_{0}t} k\in Z\}$$ $$B\subset C$$
We have:

The equation above can be deducted then:

## Fourier's Idea

### Example

composition in graph

Periodic signals & Fourier Series Expansion cont.

### Some simple theory

time frequency
period discrete
non-period continuous

### deduction

$$a_{k}$$ is denoted as Fourier coefficient.