Text File With Header

  • Follow


Hi,

I have a matrix that I would like to write to a text file. I need however to add a title and some comentary at the top of the text file before the matrix I have is written. I can't seem to find a method to do this. Any Suggestions?

Thanks
0
Reply Charles 5/11/2010 6:05:22 PM

Charles wrote:
> Hi,
> 
> I have a matrix that I would like to write to a text file. I need 
> however to add a title and some comentary at the top of the text file 
> before the matrix I have is written. I can't seem to find a method to do 
> this. Any Suggestions?

doc fprintf  % you can write whatever you wish however you wish

Isn't a generic textwrite() function similar to textread(), though, so 
you'll have to "roll your own".

--
0
Reply dpb 5/11/2010 6:24:47 PM


"Charles " <charles.vaughan.ctr@schriever.af.mil> wrote in message <hsc692$mrh$1@fred.mathworks.com>...
> Hi,
> 
> I have a matrix that I would like to write to a text file. I need however to add a title and some comentary at the top of the text file before the matrix I have is written. I can't seem to find a method to do this. Any Suggestions?
> 
> Thanks

Piecing together some examples from "doc fprontf", we have:

x = 0:.1:1;
y = [x; exp(x)];
fid = fopen('exp.txt', 'wt');
fprintf(fid,'It''s Friday.\n');
fprintf(fid, '%6.2f %12.8f\n', y);
fclose(fid)

type exp.txt

It's Friday.
  0.00   1.00000000
  0.10   1.10517092
  0.20   1.22140276
  0.30   1.34985881
  0.40   1.49182470
  0.50   1.64872127
  0.60   1.82211880
  0.70   2.01375271
  0.80   2.22554093
  0.90   2.45960311
  1.00   2.71828183
0
Reply someone 5/11/2010 6:36:04 PM

2 Replies
441 Views

(page loaded in 0.038 seconds)

Similiar Articles:













7/23/2012 7:43:37 PM


Reply: