how to convert matrix column into separate text?

2 次查看(过去 30 天)
Hi all, I have a 365*45 matrix, which represents one-year data for 45 subbasins. I would like to convert each column of the matrix to a separate text file (45 text file with a year data) and naming the file as subbasin_1, subbasin_2 etc. Any thought would be highly appreciated.

采纳的回答

Rik
Rik 2017-6-20
You obviously did not Google/Bing/Yahoo this.
You can use a loop, combined with sprintf to do this.
for n=1:45
filename=sprintf('subbasin_%d.txt',n);
fid=fopen(filename);
%
%put your writing code here
%
fclose(fid);
end
  3 个评论
Walter Roberson
Walter Roberson 2017-6-21
After the fopen() and before the fprintf(), add another fprintf() that puts in the header you want.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by