floor 함수관련 질문을 드립니다.
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Kibong Kang
le 16 Oct 2019
Commenté : Kibong Kang
le 18 Oct 2019
안녕하세요.
저는 MATLAB 2019b 버전을 사용하고 있습니다.
아래 code를 실행하였을 때, 최종적인 답이 0이 나옵니다.
LB = -0.1536;
Increment = 0.0048;
floor((LB+Increment-LB)/Increment)
제 생각에는 code의 마지막 줄은
floor(Increment/Increment)
와 동일하기 때문에 최종적으로 답이 1 이 나오는게 맞다고 생각하는데,
이상하게도 0이 나옵니다.
아래 그림은 제 PC에서 돌렸을 때의 화면을 캡쳐한 것입니다.
왜 이런 현상이 발생하는지 문의 드리고자 합니다.
0 commentaires
Réponse acceptée
Mink-Kyu Baek
le 16 Oct 2019
질문하신 (LB+Increment-LB)/Increment의 계산값은 매트랩 내부적으로 1에 음의 방향으로 아주 가까운 수로 인식하는 것 같습니다.
예를 들어서
floor(round(LB+Increment-LB,4)/Increment)
하여 4번째 자리에서 반올림을 해주게 되면 1값이 나옵니다.
도움이 되셨으면 좋겠네요.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!