1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

MATLAB fprintf function

  1. Jul 1, 2009 #1
    i am learning matlab and last week we learned the fprintf function, both for printing to the screen and for printing to file, though we only practised printing to screen,
    reading over my notes i see the \f -form feed- and \b -backspace- functions, and cannot figure out what they do,,, i tried looking for them in the help file but didnt help.

    i tried making a .txt file and using fprintf to write to it, then tried using \f and \b, but all they did was make a gap at the end of my previous text and then added whatever new text i wrote,, if that is what they do then how are they different to \t?
     
  2. jcsd
  3. Jul 1, 2009 #2

    Mark44

    Staff: Mentor

    I don't know much about MATLAB, but the fprintf function is very similar to the function of the same name from ANSI C, which I am quite familiar with. In C the fprintf function does formatted printing to a file, and since a computer display is significantly different from a printer, there are some differences. The \f and \b escape codes are form-feed and backspace (as you said). I seem to remember that \f was used to move the paper in a printer so that the next output started on a new page. If I'm remembering correctly it didn't have that much effect on a computer monitor. The \b character was supposed to move the print head back one character.

    Here's a link to some documentation on fprintf as used in MATLAB. Hope that is helpful.
    Mark
     
  4. Jul 1, 2009 #3

    MATLABdude

    User Avatar
    Science Advisor

    IIRC, MATLAB's fprintf command is supposed to have the same functionality as in C. Regarding those particular control characters, however:

    Form feed \f:
    http://en.wikipedia.org/wiki/Form_feed

    Backspace \b (when you sea^H^H^H see ^H on the internet, it's an (old) geek joke meaning that they wanted to delete a character or few before you could see it):
    http://en.wikipedia.org/wiki/Backspace
     
  5. Jul 6, 2009 #4
    I took an aerodynamics class last year and my professor gave us a few projects to get us familiar with matlab writing abilities.

    I can send you these files if you would like. I just need an email to send it to. Thanks.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: MATLAB fprintf function
  1. MATLAB Function (Replies: 0)

Loading...