How can I format some numbers and pad them with zeros?

6 Ansichten (letzte 30 Tage)
Sandy
Sandy am 10 Jun. 2016
Kommentiert: Sandy am 10 Jun. 2016
I have a data set where I have columns of data in the following format.
98.23
98.36
78.255
100.56
I basically want to have it cut off 2 digits after the decimal and pad with zeros in the front.
Example:
098.23
098.36
078.25
100.56
I've tried '%3.3f\n but I can't get the zero padding to work. Please help and thank you! :)

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 10 Jun. 2016
Bearbeitet: Azzi Abdelmalek am 10 Jun. 2016
A=[8.23
98.36
78.255
100.56]
B=sprintf('%06.2f\n',A)

Weitere Antworten (0)

Kategorien

Mehr zu Data Types 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!

Translated by