FAST QUESTION! How to round a variable to the first decimal number
2 次查看(过去 30 天)
显示 更早的评论
Hi, i have a variable like this:
Velocity = 6.76979593929292939392
And I want it to round it to this:
Velocity = 6.80
So, just one number behind the period. I have tried round(Velocity,1) but it did not work.
Thanks!
0 个评论
采纳的回答
Azzi Abdelmalek
2015-2-4
编辑:Azzi Abdelmalek
2015-2-4
Velocity = 6.76979593929292939392
out=round(Velocity*10)/10
Look also at
help fix
help ceil
0 个评论
更多回答(1 个)
Guillaume
2015-2-4
Since R2014b, round accepts a number of digits to round to:
Velocity = round(Velocity, 1);
In older versions of matlab, you have to use Azzi's answer.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!