Add label to TXT file

조회 수: 4 (최근 30일)
Giuseppe Bregliozzi
Giuseppe Bregliozzi 2012년 3월 23일
Hi,
i'm using this command to create a .txt of data. The data are placed in the first row. Is there a way to add fix labels in the first row and put the data in the second row? Thanks a lot for any help.
dlmwrite('c:\data.txt', y, 'delimiter', '\t');

답변 (2개)

Kevin Holst
Kevin Holst 2012년 3월 23일
you could just add a simple fopen command prior to your dlmwrite command:
fid = fopen('c:\data.txt','w');
fprintf(fid,'H2 CO CO2 Ar');
fclose(fid)
dlmwrite('c:\data.txt',y,'-append','delimiter','\t');

Giuseppe Bregliozzi
Giuseppe Bregliozzi 2012년 3월 23일
Hi Thanks for the answer, but in that case I have the "Your text Here" always in the cell attached to the data:
This is what I got from Matlab: 1 5 15 3
And I would like to have something like that. The first row shall be always the same.
H2 CO CO2 Ar
1 5 15 3
  댓글 수: 1
Kevin Holst
Kevin Holst 2012년 3월 23일
The intent was for you to replace 'Your Text Here' with the line that you're wanting. In this case my understanding is that you would want fprintf(fid,'H2 CO CO2 Ar');
I've adjusted my answer accordingly.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by