Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

MATLAB Write result to txt file

  1. Jun 27, 2008 #1
    Hey All,
    Quick question hope someone can help.
    Does anyone know how to write the result from a program in MATLAB to a text file ?
    I have googled this question to no avail.
  2. jcsd
  3. Jun 27, 2008 #2


    User Avatar
    Homework Helper
    Gold Member

    If you want to save variables to a text file, try the save command.

    For formatted output, try the fprintf command
  4. Jun 27, 2008 #3
    Cheers siddharth I will have a gander.
  5. Jul 1, 2008 #4


    User Avatar

    you can search google by the keyword : matlab file io
    then ,you will get the result you wanted
  6. Feb 3, 2010 #5
    i want to save my output in text file. i use for loop so it produce n outputs.i want to save all the output in my single file
  7. Feb 4, 2010 #6


    User Avatar
    Science Advisor

    Welcome to PhysicsForums!

    If your outputs are numbers, concatenate your numbers together into an array and then save using the save command (type 'help save' to figure out how to get ASCII output). Otherwise, you'll need to use fprintf.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook