Saving a text file

2020-04-30 01:45发布

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?

标签: matlab file save
1条回答
Lonely孤独者°
2楼-- · 2020-04-30 02:04

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)
查看更多
登录 后发表回答