How to convert double value to int value?
조회 수: 702 (최근 30일)
이전 댓글 표시
Hi everyone
I have probelm in my matlab code
I want to convert double value to int
d= 5.2 the result will be d=5
thank you
댓글 수: 0
채택된 답변
Dyuman Joshi
2023년 3월 14일
편집: Dyuman Joshi
님. 2023년 3월 14일
If you want to round the number -
d=5.2;
%smallest integer less or equal to input
floor(d)
%nearest integer to the input
round(d)
If you want to convert the number from double to an integer data type -
class(d)
%Choose an integer data type and use the number as input
D=int32(d)
class(D)
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!