How to format matlab such that vectors have whole number entries?
4 views (last 30 days)
Show older comments
Monique Burns
on 24 Oct 2020
Commented: Monique Burns
on 25 Oct 2020
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.
0 Comments
Accepted Answer
Walter Roberson
on 24 Oct 2020
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)
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!