function msd = msd(v1,v2)
% MSD: find mean squared difference between two
%      vectors.
%
% Code written by Katherine Smith, 2003
%
%    GENERAL
%
%      msd = msd(v1,v2)
%
%    INPUT/S
%
%      -v1,v2:
%           Vector 1 and vector 2
%           
%    OUTPUT/S
%
%      -msd:
%           Mean squared difference as calculated from the two
%           vectors
%
%    PENDING WORK
%
%      -
%
%    KNOWN BUG/S
%
%      -
%
%    COMMENT/S
%
%      -
%
%    RELATED FUNCTION/S
%
%      
%
%    ABOUT
%
%      -Created:     November 23rd, 2003
%      -Last update: Novermber 25th, 2003
%      -Revision:    0.0.2
%      -Author:      R. S. Schestowitz, University of Manchester
% ==============================================================

if(size(v1) ~= size(v2)) % ensure precondition of equal vector size
  error('Mean squared difference: vectors must be the same size');
end

differences = v1 - v2; % simple vector subtraction
squared_differences = differences .^ 2;
msd = mean(squared_differences); % get the mean of squared difference