MATLAB: How to convert matrix column into separate text

convert matrix column to separate text file with a name specifiermatrix to columnseparate column

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.

Best Answer

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