How to convert double value to int value?
612 次查看(过去 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 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!