How can I write different length and different datatypes data to a text file from matlab
3 次查看(过去 30 天)
显示 更早的评论
Right now I can only write a fixed length data to the text file ,but I need to change to a variable length data. My code:
fileID = fopen(logfilePathLocal,'at+');
formatSpec = '%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n';
fprintf(fileID,formatSpec,data{1,:});
fclose(fileID);
0 个评论
采纳的回答
更多回答(1 个)
Walter Roberson
2017-1-24
You can compute the format specification. I often construct a format using repmat and [] concatenation.
4 个评论
Jan
2017-1-25
@Walter: Sorry, I have not seen your comment, because I had this thread opened for more than an hour and forgot to press the "relaod" button of my browser. The similarity with your answer was an accident.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Low-Level File I/O 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!