UNIT Unitize a vector VN = UNIT(V) Returns a unit vector aligned with V.
0001 %UNIT Unitize a vector 0002 % 0003 % VN = UNIT(V) 0004 % 0005 % Returns a unit vector aligned with V. 0006 0007 % Copyright (C) 1990-2008, by Peter I. Corke 0008 % 0009 % This file is part of The Robotics Toolbox for Matlab (RTB). 0010 % 0011 % RTB is free software: you can redistribute it and/or modify 0012 % it under the terms of the GNU Lesser General Public License as published by 0013 % the Free Software Foundation, either version 3 of the License, or 0014 % (at your option) any later version. 0015 % 0016 % RTB is distributed in the hope that it will be useful, 0017 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0018 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0019 % GNU Lesser General Public License for more details. 0020 % 0021 % You should have received a copy of the GNU Leser General Public License 0022 % along with RTB. If not, see <http://www.gnu.org/licenses/>. 0023 0024 function u = unit(v) 0025 u = v / norm(v,'fro');