Does Matlab round matrix elements to whole numbers?

Basically I have a matrix which is 1x51 ( a row of numbers) and I perform a calculation on each number which makes them go close to 1 for example 0.9 0.8 0.78 0.99 , why does Matlab make them all 1?

 채택된 답변

Walter Roberson
Walter Roberson 2013년 2월 15일

2 개 추천

At the command prompt give the command
format long g
and then display the values. You will see that the rounding you saw was only for display purposes.

추가 답변 (1개)

Matt J
Matt J 2013년 2월 15일
편집: Matt J 2013년 2월 15일

0 개 추천

No, not all MATLAB calculations result in integers, as you should be able to readily verify, e.g., by doing
>> a=sqrt(3)
a =
1.7321
If you get a different result than I've shown, by all means assume you have an unusual problem!!

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

질문:

UCL
2013년 2월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by