============================================================== 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 ==============================================================
0001 function msd = msd(v1,v2) 0002 % ============================================================== 0003 % MSD: find mean squared difference between two 0004 % vectors. 0005 % 0006 % Code written by Katherine Smith, 2003 0007 % 0008 % GENERAL 0009 % 0010 % msd = msd(v1,v2) 0011 % 0012 % INPUT/S 0013 % 0014 % -v1,v2: 0015 % Vector 1 and vector 2 0016 % 0017 % OUTPUT/S 0018 % 0019 % -msd: 0020 % Mean squared difference as calculated from the two 0021 % vectors 0022 % 0023 % PENDING WORK 0024 % 0025 % - 0026 % 0027 % KNOWN BUG/S 0028 % 0029 % - 0030 % 0031 % COMMENT/S 0032 % 0033 % - 0034 % 0035 % RELATED FUNCTION/S 0036 % 0037 % 0038 % 0039 % ABOUT 0040 % 0041 % -Created: November 23rd, 2003 0042 % -Last update: Novermber 25th, 2003 0043 % -Revision: 0.0.2 0044 % -Author: R. S. Schestowitz, University of Manchester 0045 % ============================================================== 0046 0047 if(size(v1) ~= size(v2)) % ensure precondition of equal vector size 0048 error('Mean squared difference: vectors must be the same size'); 0049 end 0050 0051 differences = v1 - v2; % simple vector subtraction 0052 squared_differences = differences .^ 2; 0053 msd = mean(squared_differences); % get the mean of squared difference