Home MATLAB is rounding off to nearest integer

# MATLAB is rounding off to nearest integer

Abdul kareem
1#
Abdul kareem Published in 2017-05-08 04:11:22Z
 I have a 1x50000 size matrix v and I want to convert it to zero mean and unit variance: x = ((v-mean(v))/std2(v));  But instead of giving me exact floating point values MATLAB is converting it to nearest integers. Please help me in getting the exact values.
gnovice
2#
 Check the data type for v. I'm sure it's an integer type, using integer arithmetic, which is why the result is an integer. You need to convert it to a floating point type to perform floating point operations on it: v = double(v); % Convert v to a double-precision float x = ((v-mean(v))/std2(v)); % Result is now a double as well