How to print data from cell array to a text file ?
3 次查看(过去 30 天)
显示 更早的评论
Dear programmers
I have a cell array(FINALSHEET) as provided in the image file. I need to write the contents of FINALSHEET{1,1} (which is having only integer values) and FINALSHEET{1,2}( which is having only floating values) in a text file say, matlab_data.txt. I have tried a code as shown below but it concetanates both FINALSHEET{1,1} and FINALSHEET{1,2}. Please help.
FINALSHEET= { diffusion{1,1}{1,1}, YMF};
fid = fopen('matlab_data.txt','w');
for row = 1:1:16356
fprintf(fid ,'%d %f \n', FINALSHEET{1,1}{row,:},FINALSHEET{1,2}{row,:});
end
fclose(fid)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/250744/image.jpeg)
0 个评论
采纳的回答
Marcel Kreuzberg
2019-11-27
try
fprintf(fid ,'%d %f \r\n', FINALSHEET{1,1}{row,:},FINALSHEET{1,2}{row,:});
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!