Saving to text file from cell array
2 次查看(过去 30 天)
显示 更早的评论
Dear colleagues,
we have a cell array like the one below, we obtained from a txt file:
[34] [12] 'xxx'
[3] [1] 'www'
[21] [2] 'qwe'
[11] [12] 'awk'
[34] [x] 'sed'
we just want to save it as a matrix text file with the same dimensions once again, afer having applied some replacement loops.
dlmwrite doesn't work (we're not dealing with matrixes)
save has unsupported Ascii..
fprintf ! It's the whole day we're struggling with it. Here is our code:
column1 = num2cell(colum1_from_txtfile)
column2 = num2cell(colum2_from_txtfile)
column3 = cellstr(colum3_from_txtfile)
M = [column1 column2 column3]
% our loops
fid = fopen('another_txtfile', 'wt')
fprintf(fid, '%d%d%s\t\n', M)
??? Error using ==> fprintf
Function is not defined for 'cell' inputs.
We guess the whole problem is about the value types we're using in the fprintf argument (%s %d ..).
We would be absolutely happy if anybody could provide as with suggestions!
Best,
Udiubu & Co.
1 个评论
Walter Roberson
2012-3-5
Is this a different question than your earlier http://www.mathworks.com/matlabcentral/answers/31231-txt-file-to-cell-array-to-text-file
?? If so then it would be best to indicate the difference, as otherwise someone is likely to mark it as a duplicate question that requires merging.
回答(2 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!