write cell data into text file
When the elements in a cell matrix is numeric, like:
a = cell(10,1) for i = 1:10 a{i} = i; end % then, the following script should be like this: fileID = fopen('celldata.txt','wt') for row = 1:10 fprintf(fileID,'%s\n' ,num2str(a{row,:})); end fclose(fileID);
There are two tricky points in this script.
1. fopen('celldata.txt','wt') is really important. When it is changed to fopen('celldata.txt','w'), '\n' doesn't work on windows. As Jan Simon concluded, '\n' depends on the platform.
2. num2str is necessary, otherwise, it will be some weird squares in your file.