help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: save matrix with a header


From: Markus Bergholz
Subject: Re: save matrix with a header
Date: Thu, 30 Jan 2014 13:01:50 +0100




On Thu, Jan 30, 2014 at 12:53 PM, Marcio Cardoso <address@hidden> wrote:
M = [ 1, 20; 2, 21; 3, 22];
dlmwrite('c:\testresult\M.txt', M, '\t')

Works fine, but I would like to add a header for the file.
The matrix header shall be the columns names: 'day'   'temperature(C)'

how can I save the matrix with the header?
Regards



octave:1> fid = fopen('file.txt','wt');
octave:2> fprintf(fid, 'day\ttemperature\n');
octave:3> fclose(fid);
octave:4> dlmwrite('file.txt', rand(2,2),'delimiter', '\t', '-append');
octave:5> system('cat file.txt')
day    temperature
0.8379681793263363    0.6296502710312603
0.978808957235874    0.7942579903688513
ans =                    0
octave:6>




 



_______________________________________________
Help-octave mailing list
address@hidden
https://mailman.cae.wisc.edu/listinfo/help-octave




--
icq: 167498924
XMPP|Jabber: address@hidden

reply via email to

[Prev in Thread] Current Thread [Next in Thread]