From: Charles on
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
From: dpb on
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".

--
From: someone on
"Charles " <charles.vaughan.ctr(a)schriever.af.mil> wrote in message <hsc692$mrh$1(a)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