简体   繁体   中英

Saving a text file

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?

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM