How to use Floor command
이전 댓글 표시
I have some wrong thing with floor command. This problem is that
Step 1: Initial step
t=[0.90 1.00 1.30 1.80 1.90];
step = (t(5)-t(1))/100;
time = t(1):step:10;
Step 2: Check floor command
time(181)
ans =
2.7000
floor((time(181)-0.9)/(2*0.9))
ans =
0
*But i realize that*
floor((2.7-0.9)/(2*0.9))
ans =
1
What problem was happen in this case?
Question 2: Logic condition
t_ = 4.5 - 4*0.9
t_ =
0.9000
t_ >= 0.9
ans =
0
But
0.9>=0.9
ans =
1
채택된 답변
추가 답변 (3개)
You're not accounting for floating point errors.
4.5 - 4*0.9
will not give you precisely 9/10, but rather something accurate to many decimal places.
Honglei Chen
2012년 10월 4일
0 개 추천
This has nothing to do with floor, it's part of the floating point computation. See the link below
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!