问题
I have a cell array with the size of 1*15.
whos C
Name Size Bytes Class Attributes
C 1x15 222520 cell
In each cell, there are 1170 elements. The 15 cells are mixture of strings and numbers. I want to save all these elements to a text file with coma as delimiter.
I tried to use the function dlmcell, dlmcell('file_out.txt.,C,'delimiter',','), it can only write the first value of each cell to the text file. And the cell contains string cannot be write to the text file.
Can anyone help? Thanks!
回答1:
I just found in http://cn.mathworks.com/help/matlab/import_export/write-to-delimited-data-files.html write cell data using fprintf. May help!
[nrows,ncols] = size(C);
for row = 1:nrows
fprintf(fileID,formatSpec,C{row,:});
end
来源:https://stackoverflow.com/questions/27708871/write-a-cell-array-in-text-file-using-matlab