function index = findLongest3DVector(vectors) if (size(vectors,2) ~= 3) error('You should provide an Nx3 vector array'); index = 0; return end type = 2; dimension = 2; norms = vecnorm(vectors,type,dimension); index = find(norms == max(norms)); end