保存文本文件 [英] Saving a text file
问题描述
我想将矩阵另存为具有可变文件名的.text.目前,我正在使用功能dlmwrite(name,matrix);保存文件.这仅适用于预设的文件名.有没有一种方法可以使文件名可变?
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?
一个弹出的窗口要求打开一个文件名,就像'Uigetfile'与打开文件一样.有人知道Matlab是否具有与编写文本文件一样的功能吗?
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?
推荐答案
You can use uiputfile
to graphically get the file name. For example:
[filename, pathname, filterindex] = uiputfile('', 'Select file');
然后使用dlmwrite
将变量(例如data
)保存到该文件:
Then use dlmwrite
to save a variable, say data
, to that file:
dlmwrite(fullfile(pathname, filename), data)
这篇关于保存文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!