Three-digit format

30 visualizzazioni (ultimi 30 giorni)
J T
J T il 21 Ago 2020
Risposto: Sara Boznik il 21 Ago 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!

Risposta accettata

Walter Roberson
Walter Roberson il 21 Ago 2020
%.3g

Più risposte (1)

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

Categorie

Scopri di più su Get Started with MATLAB in Help Center e File Exchange

Prodotti


Release

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by