Three-digit format

19 Ansichten (letzte 30 Tage)
J T
J T am 21 Aug. 2020
Beantwortet: Sara Boznik am 21 Aug. 2020
Hello,
I am looking for a format such that:
fprintf( format , 1.1111111); gives 1.11
fprintf( format , 11.111111); gives 11.1
fprintf( format , 111.11111); gives 111
That is 3 digits in total regadless of the decimal point, thanks!

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 21 Aug. 2020
%.3g

Weitere Antworten (1)

Sara Boznik
Sara Boznik am 21 Aug. 2020
Hi
I suggest you that you use:
fprintf('%.3g',1.111111)

Kategorien

Mehr zu Introduction to Installation and Licensing finden Sie in Help Center und File Exchange

Produkte


Version

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by