LinearVelocity - Compute instantaneous linear velocity. Compute linear velocity for a time-varying vector X. USAGE V = LinearVelocity(X,smooth) X position <a href="matlab:help samples">samples</a> smooth optional standard deviation for Gaussian kernel used for differentiating, measured in number of samples (default = no smoothing) SEE See also AngularVelocity.
0001 function V = LinearVelocity(X,smooth) 0002 0003 %LinearVelocity - Compute instantaneous linear velocity. 0004 % 0005 % Compute linear velocity for a time-varying vector X. 0006 % 0007 % USAGE 0008 % 0009 % V = LinearVelocity(X,smooth) 0010 % 0011 % X position <a href="matlab:help samples">samples</a> 0012 % smooth optional standard deviation for Gaussian kernel used for 0013 % differentiating, measured in number of samples 0014 % (default = no smoothing) 0015 % 0016 % SEE 0017 % 0018 % See also AngularVelocity. 0019 0020 % Copyright (C) 2004-2011 by Michaƫl Zugaro 0021 % 0022 % This program is free software; you can redistribute it and/or modify 0023 % it under the terms of the GNU General Public License as published by 0024 % the Free Software Foundation; either version 3 of the License, or 0025 % (at your option) any later version. 0026 0027 if nargin < 1, 0028 error('Incorrect number of parameters (type ''help <a href="matlab:help LinearVelocity">LinearVelocity</a>'' for details).'); 0029 end 0030 if nargin >= 2, 0031 if ~isdscalar(smooth,'>=0'), 0032 error('Incorrect smoothing stdev (type ''help <a href="matlab:help LinearVelocity">LinearVelocity</a>'' for details).'); 0033 end 0034 else 0035 smooth = 0; 0036 end 0037 0038 DX = Diff(X,'smooth',smooth); 0039 Y = DX(:,2:3).*DX(:,2:3); 0040 N = sqrt(Y(:,1)+Y(:,2)); 0041 V = [X(:,1) N];