% part b, number 1, homework set 1
% this script takes in any vector of even length, and swaps
% the last half of the entries with the first half:
% example:  [1,2,3,4] --> [3,4,1,2]

  x = input('Please enter a vector x in the form [x1,x2, x3,...,xn]:');

  n = length(x);

%test if length of vector x is even:
  if (n/2) == floor(n/2)
  
  % if so, swap last half with first half to obtain 
  % resulting vector y
    y(1:n/2) = x(n/2+1:n);
    y(n/2+1:n) = x(1:n/2);
    
  % if not, return error message indicating nature of error	
  else
    'error - the vector is not of even length.  please run the program again'
  end



