MATLAB: How to format matlab such that vectors have whole number entries

#formatwholenumbers

I am wondering how to get matlab to produce vectors with whole numbers. For example, when I'm trying to find the eigenvectors of a matrix, one eigenvector in the output is (0.4472, -0.4472, 0.4472, 0.4472, 0.4472, 0)', which is obviously just (equivalent to) (1, -1, 1, 1, 1, 0)'. How do I get matlab to output the latter vector instead? Thanks very much.

Best Answer

temp = eigen_vectors;
temp(temp==0) = inf; %avoid 0 as the min
colmin = min(abs(temp),[],1);
scaled_vectors = eigen_vectors./colmin %requires R2016b or later
For earlier releases you could bsxfun(@rdivide, eigen_vectors, colmin)