How to save a variable in text file
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, I am trying to save the values in a variable to a text file. I used "-ascii" with the save command but the values in the text file are different from the one present in d variable.
temp_var=1000; save mat_to_text.txt '-ASCII'temp_var
now the contents of text file is
//mat_to_text.txt
1.0000000e+003
but the contents should be 1000.
Can somebody please help me with this! Thanks in advance :)
0 commentaires
Réponse acceptée
Stephen23
le 16 Fév 2015
Modifié(e) : Stephen23
le 16 Fév 2015
Actually 1.0000000e+003 is 1000.
These are just different ways of writing the same number, so you really don't need to change anything.
This way of writing numbers is called E-notation, which is a kind of scientific notation, and it is commonly used to store numbers in text data in science and engineering. One of its main advantages is the exact representation of the number of significant figures of the values. Scientific notation also lets you save numbers that are very large or very small without having to print lots of zeros: can you imagine how many characters 1.000E+300 would require if one didn't use scientific notation?
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Data Import and Export dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!