function [mag] = vecmag(x,y,z) %% Tiny function to find the mag of 2 or 3 vectors % Because I'm tired of writing sqrt % Alexander Rey, Queen's University, Oct 30 2019 if nargin == 1 mag = x; elseif nargin == 2 mag = sqrt(x.^2+y.^2); elseif nargin == 3 mag = sqrt(x.^2+y.^2+z.^2); end end