How to save a variable in text file
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Suresh R
am 16 Feb. 2015
Bearbeitet: Stephen23
am 16 Feb. 2015
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 Kommentare
Akzeptierte Antwort
Stephen23
am 16 Feb. 2015
Bearbeitet: Stephen23
am 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Large Files and Big Data 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!