Saving a text file

扶醉桌前 提交于 2019-12-02 11:41:39

问题


I want to save a matrix as .text with a variable filename. Currently I'm saving my file using the function dlmwrite(name,matrix); This is only working with a pre-set filename. Is there a way to make the name of the file variable?

A window that pops up that ask for a filename to write to just as 'Uigetfile' does with opening a file would be ideal. Does anyone know if Matlab got a function just like that for writing text files?


回答1:


You can use uiputfile to graphically get the file name. For example:

[filename, pathname, filterindex] = uiputfile('', 'Select file');

Then use dlmwrite to save a variable, say data, to that file:

dlmwrite(fullfile(pathname, filename), data)


来源:https://stackoverflow.com/questions/21335577/saving-a-text-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!