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 % usage in output data

  1. Sep 18, 2012 #1
    Matlab fprintf "%" usage in output data

    I want to save data into a textfile, but I will again need matlab to read that text file, in which
    case, I would like to have my header-text of the data table begin with '%"
    so that when I am reading from than file, matlab will ignore header.

    I am getting error in doing so. Can somebody please help me ?

    thank you !
  2. jcsd
  3. Sep 18, 2012 #2


    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    Re: Matlab fprintf "%" usage in output data

    If I understand correctly, you are encountering an error when trying to print the % symbol using fprintf. That is because % has a special meaning to fprintf. It is used for formatting numbers. If you want to print the symbol itself, you have to put %% instead of %. Example:

    fprintf(fid, '%% this is a comment\n');
  4. Sep 19, 2012 #3
    Re: Matlab fprintf "%" usage in output data

    Perfect ! this did help me. I Was trying to print "%". and %% is the solution thanks again
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Threads - Matlab fprintf usage Date
MATLAB and the command fprintf Jul 2, 2015
MATLAB fprintf function Sep 15, 2012
(quick) Matlab fprintf question Aug 23, 2012
Matlab beginner fprintf into .txt Nov 5, 2011
Matlab fprintf Apr 22, 2011