view general/numerical/vecshift.m @ 4:e44f49929e56

Adding reorganised general toolbox, now in several subdirectories.
author samer
date Sat, 12 Jan 2013 19:21:22 +0000
parents
children
line wrap: on
line source
function Y=vecshift(O,X)
% vecshift - refer an array of vectors to a new origin.
%
% This SUBTRACTS the first argument (a vector) from each
% of the vectors (row or column) in the second argument.
% Works in two modes: row vector or column vector mode.
%
% vecshift :: 
%    [[N,1]] ~'new origin', 
%    [[N,M]] ~'array of vectors, array domain is M'
% -> [[N,M]] ~'vectors relative to new origin'.
%

% note: this now works for any pair of arrays where size O
% is an integer fraction of size X in any dimension
Y=X-repmat(O,1,size(X,2));