Save data to .mat file
4 次查看(过去 30 天)
显示 更早的评论
How can I save data to a mat file? I just want to create 10 column mat file. I also want column headings in the first row of each column.
0 个评论
采纳的回答
Walter Roberson
2016-9-27
http://www.mathworks.com/matlabcentral/answers/304447-creating-a-matrix-from-mat-files#answer_236050
Once you had created the table described there, you can save() it to a .mat file.
Are you trying to create a text output file or a binary output file?
If you are trying to save to a text file with column headers, then really the best way is to fopen(), fprintf() the headers, fprintf() the data, and then fclose().
If you are trying to save to a text file with column headers, and you really feel a need to use save, then use fopen(), fprintf() the headers, fclose(). Then use
save TheMatFileName -ascii -tabs -append TheVariableName
If you are trying to save in binary form and you need column headers then you need to use a table() object (described in the link above), or you need to use a dataset() object from the Statistics toolbox. Those are the only kinds of rectangular arrays that support column headers.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Text Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!