Ns = 5;
N = 256*Ns;
Nd = N/Ns;
n = [-N/2:N/2-1];
x = sinc(n/8);
X = fftshift(fft(fftshift(x)));
figure(1)
subplot(211)
stem(n,x)
axis([-50 50 -.5 1])
ylabel('x(n)');
xlabel('n');
subplot(212)
om = n./N*2*pi;
plot(om,real(X))
ylabel('X(\omega)');
xlabel('\omega');

xs = zeros(size(x));
xs(1:Ns:end) = x(1:Ns:end);  % sampled version
Xs = fftshift(fft(fftshift(xs)));

figure(2)
subplot(211)
stem(n,xs)
axis([-50 50 -.5 1])
ylabel('x_s(n)');
xlabel('n');
subplot(212)
om = n./N*2*pi;
plot(om,real(Xs))
ylabel('X_s(\omega)');
xlabel('\omega');

xd = x(1:Ns:end);            % decimated version
nd = [-N/2:Ns:N/2-1];        % sample locations
xr = interp1(nd,xd,n,'nearest');
xr(find(isnan(xr))) = 0;
Xr = fftshift(fft(fftshift(xr)));

