Matlab fprintf % usage in output data

  • Context: MATLAB 
  • Thread starter Thread starter karna87
  • Start date Start date
  • Tags Tags
    Data Matlab Output
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 4K views
karna87
Messages
7
Reaction score
0
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 !
 
on Phys.org


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');
 


Perfect ! this did help me. I Was trying to print "%". and %% is the solution thanks again