0
$\begingroup$

My original signal as

f1=2;
f2=5;

fs=100;
Ts=1/fs;
t=0:Ts:1;

xt=cos(2*pi*f1*t)+cos(2*pi*f2*t);

figure
plot(t,xt)

as shown below figure.

enter image description here

and my sampled signal with fs=12 which is greater than two times of maximum frequency, 2*f2=10;

fs=12;
Ts=1/fs;
tn=0:Ts:1;

xn=cos(2*pi*f1*tn)+cos(2*pi*f2*tn);

enter image description here

and then I want to reconstruct the original signal with sampled signal.

I tried it using the matlab function interp1 as below

xr=interp1(tn,xn,t,'spline');

I compared original signal and reconstructed signal, but they are different as shown below figure.

enter image description here

How to reconstruct original signal?

$\endgroup$

2 Answers 2

1
$\begingroup$

Sinc interpolation can exactly reconstruct an above-Nyquist-sampled strictly bandlimited signal from noiseless samples. See the Whittaker-Kotelnikov-Shannon reconstruction or resampling theorem: https://en.wikipedia.org/wiki/Whittaker–Shannon_interpolation_formula and https://ccrma.stanford.edu/~jos/resample/Theory_Ideal_Bandlimited_Interpolation.html

For computation, you can try using a windowed Sinc (or other near-brick-wall linear phase low pass filter) for a more reasonable finite length interpolation kernel. For any finite length of samples, both the band-limit and the low-pass reconstruction filter's stop-band need to be strictly below (NOT equal to) half the sampling rate. Due to finite window length, and finite-precision floating point sampling and arithmetic, you may see some end effects and other reconstruction differences.

$\endgroup$
2
  • $\begingroup$ Thank you so much. $\endgroup$
    – agile
    May 17, 2021 at 7:13
  • $\begingroup$ For ideal Sinc interpolation you need an infinite number of samples. A windowed Sinc allows you to use a finite set of samples, but you are going to have end effects and the beginning and end of your data i.e. where you run out of data. $\endgroup$
    – David
    May 17, 2021 at 14:18
1
$\begingroup$

To implement a digital-to-analog converter, all you need is an ideal low-pass filter to filter out the periodic frequency response that $\varOmega \geq \varOmega_s/2$.

$$ H(j\varOmega) =\left\{ \begin{aligned} T,\ \ \ \ |\varOmega|<\varOmega_s/2 \\ 0,\ \ \ \ |\varOmega|\geq\varOmega_s/2 \end{aligned} \right. $$

The impulse response of an ideal low-pass filter is a sinc function

$$ h(t) = \frac{\sin(\pi t/T)}{\pi t/T} $$

Convolving the sampled signal with this impulse response gives the analog signal.

$$ \begin{aligned} y_a(t) =& \sum_{n=-\infty}^{\infty} x_a(nt) h(t-nT)\\ =&\sum_{n=-\infty}^{\infty} x(n) \frac{\sin[\pi (t-nT)/T]}{\pi (t-nT)/T} \end{aligned} $$

f1=2;
f2=5;

fs=100;
Ts=1/fs;
t=0:Ts:1;
xt=cos(2*pi*f1*t)+cos(2*pi*f2*t);
figure
plot(t,xt)

fs=12;
Tn=1/fs;
tn=0:Tn:1;
xn=cos(2*pi*f1*tn)+cos(2*pi*f2*tn);
hold on
stem(tn, xn)

y = dac(xn, Tn, t);
plot(t,y)


function y = dac(x, T, t)
m = 0:length(x)-1;
y = zeros(1, length(t));
for ii = 1:length(t)
    h = sinc((t(ii)-m*T)/T);
    y(ii) = sum(x .* h);
end
end
$\endgroup$
1
  • $\begingroup$ Thank you so much. $\endgroup$
    – agile
    May 17, 2021 at 7:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.