FAST QUESTION! How to round a variable to the first decimal number
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Peter
am 4 Feb. 2015
Beantwortet: Guillaume
am 4 Feb. 2015
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 Kommentare
Akzeptierte Antwort
Azzi Abdelmalek
am 4 Feb. 2015
Bearbeitet: Azzi Abdelmalek
am 4 Feb. 2015
Velocity = 6.76979593929292939392
out=round(Velocity*10)/10
Look also at
help fix
help ceil
0 Kommentare
Weitere Antworten (1)
Guillaume
am 4 Feb. 2015
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 Kommentare
Siehe auch
Kategorien
Mehr zu Fourier Analysis and Filtering finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!