How to reconstruct original signal from sampled signal?
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|&lt;\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) =&amp; \sum_{n=-\infty}^{\infty} x_a(nt) h(t-nT)\\
=&amp;\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