% Written by: Daniel Llamocca (2013)
% TIME SHIFTING of discrete time signals

clear all; % clears any previously-generated variables
close all; % close all windows
clc; % clears MATLAB command screen

% Generating vector of samples:
  n = -20:20; % [-20 -19.... 20]

% Creating the input signal x[n]:
  x = sin(n/10); % 'n/10' instead of 'n' already explained
  
% Time shifting:
% We have x[n], now we want y[n] = x[n - n0]
% In x[n]=sin(n/10), 'n' is replaced by 'n-n0' --> y[n] = sin((n-n0)/10)
  n0 = 10; % 'n0' samples
  y = sin((n - n0)/10);
  
figure; stem (n, x, '.b'); grid on; title ('x[n]');
figure; stem (n, y, '.b'); grid on; title ('y[n] = x[n-n0]');