]> Creatis software - CreaPhase.git/blob - octave_packages/nurbs-1.3.6/vecmag.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / nurbs-1.3.6 / vecmag.m
1 function mag = vecmag(vec)
2
3 % VECMAG: Magnitude of the vectors.
4
5 % Calling Sequence:
6
7 %   mvec = vecmag(vec)
8
9 % INPUT:
10
11 %   vec         : An array of column vectors represented by a matrix of
12 %               size (dim,nv), where is the dimension of the vector and
13 %               nv the number of vectors.
14 %
15 % OUTPUT:
16 %
17 %   mvec        : Magnitude of the vectors, vector of size (1,nv).
18
19 % Description:
20
21 %   Determines the magnitude of the vectors.
22
23 % Examples:
24
25 %   Find the magnitude of the two vectors (0.0,2.0,1.3) and (1.5,3.4,2.3)
26
27 %   mvec = vecmag([0.0 1.5; 2.0 3.4; 1.3 2.3]);
28 %
29 %    Copyright (C) 2000 Mark Spink
30 %
31 %    This program is free software: you can redistribute it and/or modify
32 %    it under the terms of the GNU General Public License as published by
33 %    the Free Software Foundation, either version 2 of the License, or
34 %    (at your option) any later version.
35
36 %    This program is distributed in the hope that it will be useful,
37 %    but WITHOUT ANY WARRANTY; without even the implied warranty of
38 %    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
39 %    GNU General Public License for more details.
40 %
41 %    You should have received a copy of the GNU General Public License
42 %    along with this program.  If not, see <http://www.gnu.org/licenses/>.
43
44 mag = sqrt(sum(vec.^2));
45
46 end