How to save a variable in text file
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Stephen23
il 16 Feb 2015
Modificato: Stephen23
il 16 Feb 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Data Import and Export in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!