필터 지우기
필터 지우기

MATLAB error in counting

조회 수: 2 (최근 30일)
Adam
Adam 2012년 4월 18일
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??
  댓글 수: 1
Adam
Adam 2012년 4월 18일
good, as I do that the result was the same as on a calculator?

댓글을 달려면 로그인하십시오.

채택된 답변

Friedrich
Friedrich 2012년 4월 18일
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)
  댓글 수: 2
Adam
Adam 2012년 4월 18일
str = ['označena plocha je 2 ', num2str(voxsuma2), ' mm^2.']
do not understand why but when I removed the "2" so it goes well
str = ['označena plocha je',num2str(voxsuma2),'mm^2.'];
thank you much for the quick help and advice
Friedrich
Friedrich 2012년 4월 18일
Its a formatting thing, the num2str works correct. take the number you see on the screen 215379.4968 and ignore the 2 in front of it and you will get 15379.4968. The 2 you see is the 2 you print before it with the text string "je 2". Its like a typo. The 2 doenst belong to the value which num2str gives but it looks like it does.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Ilham Hardy
Ilham Hardy 2012년 4월 18일
Just realized that!

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by