Matlab fprintf % usage in output data

  • MATLAB
  • Thread starter karna87
  • Start date
  • #1
7
0

Main Question or Discussion Point

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 !
 

Answers and Replies

  • #2
jbunniii
Science Advisor
Homework Helper
Insights Author
Gold Member
3,394
179


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');
 
  • #3
7
0


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

Related Threads for: Matlab fprintf % usage in output data

  • Last Post
Replies
6
Views
9K
Replies
7
Views
6K
Replies
4
Views
719
  • Last Post
Replies
1
Views
3K
Replies
5
Views
5K
  • Last Post
Replies
1
Views
9K
Replies
2
Views
4K
  • Last Post
Replies
1
Views
13K
Top