MATLAB: MATLAB error in counting

MATLABnum2strstrsummation

How is it possible that my calculator comes out a different result than matlab calculated?
>> suma2= 7874;
voxsuma2=suma2*2*0.9766;
str = ['označena plocha je 2', num2str(voxsuma2), ' mm^2.']
str =
označena plocha je 215379.4968 mm^2.
a calculator:7874*2=15748
15748*0.9766=15379,4968
15379,4968 or 215379.4968 is correct? WTH??

Best Answer

Hi
num2str is correct here, but the missing space after the 2 makes the result looking wrong, because the correct number 15379.4968 appears right after the 2. Try
suma2= 7874;
voxsuma2=suma2*2*0.9766;
str = ['označena plocha je 2 ', num2str(voxsuma2), ' mm^2.']
(Note the extra space after "je 2" before the num2str)