How to save a variable in text file
7 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Stephen23
on 16 Feb 2015
Edited: Stephen23
on 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 Comments
More Answers (0)
See Also
Categories
Find more on Data Import and Export in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!