Matlab fprintf % usage in output data

  • MATLAB
  • Thread starter karna87
  • Start date
  • #1
karna87
7
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 !
 

Answers and Replies

  • #2
jbunniii
Science Advisor
Homework Helper
Insights Author
Gold Member
3,475
257


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
karna87
7
0


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

Suggested for: Matlab fprintf % usage in output data

  • Last Post
Replies
2
Views
614
Replies
1
Views
413
  • Last Post
Replies
6
Views
86
  • Last Post
Replies
1
Views
397
  • Last Post
Replies
4
Views
204
  • Last Post
Replies
12
Views
2K
Replies
1
Views
445
Replies
0
Views
349
Replies
1
Views
734
Replies
10
Views
1K
Top