[Solved] How to convert decimals in a matrix to integers? [closed]


[A,B] = size(v)
for ii = 1:B
    v(:,ii) = v(:,ii)./abs(min(v(:,ii)));
end

In case this is the exact example you have.

And just in case doubles are not good enough:

v = int32(v); % or whichever integer you want

bsxfun way, thanks to @rayryeng:

v = bsxfun(@rdivide, v, abs(min(v,1)));

4

solved How to convert decimals in a matrix to integers? [closed]