fs = 1e6;
T  = 1/fs;
Td = 0.5*T;
fx = fs/29;
t = 0:T:1.2/fx;
x = sin(2*pi*fx.*t);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% time domain

plot(t, x, 'o');
hold on;
stairs(t, x, 'r');
legend('sampled data', 'after ZOH', 3);
xlabel('Time');
ylabel('Amplitude');
hold off;
fixfig;


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% spectra

f = linspace(0, 3*fs, 900);
h = (abs(cos(pi*f/fs)) .^ 0.1) - 0.8;
h(h < 0) = 0;
h = h/h(1);

s = abs(sinc(f * Td));

plot(f, h, f, s, f, h.*s);
legend('sampled signal', 'sinc', 'zoh signal', -1);
xlabel('Frequency');
ylabel('Magnitude');
fixfig;