%
%   Book: MATLAB-Based Electromagnetics (Pearson Prentice Hall)
%   Author: Branislav M. Notaros
%   Instructor Resources
%   (c) 2011
%
%   This MATLAB code or any part of it may be used only for 
%   educational purposes associated with the book
%
%
%

% Vector magnitude

% Function that calculates magnitude of the given vector 
% (row or coulumn vector).
function mag = vectorMag(vector)
[m,n]= size(vector);
if (m~=1)&&(n~=1)  
    mag = 0;
    disp('Error - vector of improper dimensions');
else
mag = sqrt(sum(vector.^2));
end;
