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

MATLAB and the command fprintf

  1. Jul 2, 2015 #1
    Hi guys i'm doing some homeworks for my professor, the homeworks are some MATLAB scripts that consist in creating and running some functions. The professor is requesting that the results obtained must be written in a file using the command fprintf.
    I have tried to understand the mechanics of the command in the documentation and in Google but i simply can not understand ANYTHING...any help?
     
  2. jcsd
  3. Jul 2, 2015 #2

    jedishrfu

    Staff: Mentor

  4. Jul 2, 2015 #3
    for example what are the commands fopen and fclose doing?
     
  5. Jul 2, 2015 #4

    jedishrfu

    Staff: Mentor

    When you work with files in any programming language, you must first open them and get a file handle to use for processing.

    Once you've completed your work then you need to close the file.

    Typically during file processing, file data is buffered so that each read or write doesn't result in a real disk read or write. Instead, several lines of data are read in and buffered awaiting for the program to read them and similarly several lines of output data are buffered and written out once the buffer is full. Closing a file flushes the remaining lines to the output file.

    Also many programming languages have runtime limits where no more than X number of files may be open at the same time. So you will see programs that open a file, do some processing and then close the file as opposed to opening all the files, keeping them open for the duration of the program and then closing them at the end in order to avoid the max number of files open limit.
     
  6. Jul 2, 2015 #5
    ok....this is one of the answers i was looking for...i worked only with Wolfram (with the easy Export[...] command) and nothing else so i never heard about this kind of stuff :p
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: MATLAB and the command fprintf
  1. Matlab fprintf (Replies: 6)

Loading...