MATLAB如何在文本文件中编写标题 [英] MATLAB how to write header in text file
本文介绍了MATLAB如何在文本文件中编写标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
code salay month
一次? 代码工资月
12 1000 12
14 1020 11
11 1212 9
fid = fopen('analysis1.txt','wt');
for i = 1:10
array = []; %清空数组
....
array = [code salary month];
格式短g;
fprintf(fid,'%g\t%g\t%g \ n',array); %写入文件
结束
fclose(fid);
解决方案
是否有任何理由不使用简单的解决方案?
...
fid = fopen('analysis1.txt','wt');
fprintf(fid,'%s\t%s\t%s\\\
','Code','Salary','Month');
for i = 1:10
array = []; %清空数组
...
How to write a text header in text file? for example in the example below, how to write the header code salay month
just once?
Code Salary Month
12 1000 12
14 1020 11
11 1212 9
The code:
fid = fopen('analysis1.txt','wt');
for i=1:10
array = []; % empty the array
....
array = [code salary month];
format short g;
fprintf(fid,'%g\t %g\t %g\n',array); % write to file
end
fclose(fid);
解决方案
Is there any reason for not using simple solution like following?
...
fid = fopen('analysis1.txt','wt');
fprintf(fid, '%s\t %s\t %s\n', 'Code','Salary','Month');
for i=1:10
array = []; % empty the array
...
这篇关于MATLAB如何在文本文件中编写标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文