How do I save a workspace variable to a .txt file?

372 views (last 30 days)
Andrew
Andrew on 21 Aug 2012
Commented: Walter Roberson on 19 Jan 2019
I tried using the 'save' function, but I can't seem to get it to work. I want to append a .txt file by saving a variable "excel" to it. I want to be able to do this repeatedly.
I tried the code
save(saving.txt, excel, '-append-')
  2 Comments
Jan
Jan on 21 Aug 2012
And I'm sure you got an error message when you run this command. Then it would be a good idea 1. to read the message, and 2. to post it here when the solution is not clear after 1.

Sign in to comment.

Accepted Answer

José-Luis
José-Luis on 21 Aug 2012
Edited: José-Luis on 21 Aug 2012
save('myFile.txt', 'excel', '-ASCII','-append');
  6 Comments
Walter Roberson
Walter Roberson on 19 Jan 2019
Without the -append every save will erase all existing content of the file.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!