function varargout = split(A) %function varargout = split(A) splits a matrix A into rows or columns % according to which matches the desired number of variables. s = size(A); if nargout == s(1), for k=1:nargout, varargout(k) = {A(k,:)}; end; else if nargout == s(2), for k=1:nargout, varargout(k) = {A(:,k)}; end; else disp(['error: list must match number of rows or columns of ' inputname(1)]); end; end