Using the command num2str

3 visualizzazioni (ultimi 30 giorni)
Khalid Alsinan
Khalid Alsinan il 11 Nov 2020
Commentato: Ameer Hamza il 11 Nov 2020
When I run:
num2str(5.7831e-04)
I get: '0.00057831'
How can I obtain '5.7831e-04' instead?

Risposte (1)

Ameer Hamza
Ameer Hamza il 11 Nov 2020
Use sprintf()
sprintf('%.4e', 5.7831e-04)
  3 Commenti
Khalid Alsinan
Khalid Alsinan il 11 Nov 2020
Never mind! Thank you so much Ameer!!
Ameer Hamza
Ameer Hamza il 11 Nov 2020
Storing a number is not a matter of format. Inside memory, it will be saved as a double datatype with same bits. The format is only important if you want to print the number.

Accedi per commentare.

Categorie

Scopri di più su Workspace Variables and MAT Files in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by