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!