How to use Floor command
Mostra commenti meno recenti
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
Risposta accettata
Più risposte (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
il 4 Ott 2012
0 voti
This has nothing to do with floor, it's part of the floating point computation. See the link below
trung trinh
il 4 Ott 2012
0 voti
Categorie
Scopri di più su Logical in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!