I wanna save text as txt file in my desktop or any location I choose

2 次查看(过去 30 天)
Text='hello' [file, path] =uiputfile('text. Txt')

回答(1 个)

Walter Roberson
Walter Roberson 2019-9-15
Text='hello';
[file, pathdir] = uiputfile('text. Txt');
if isempty(file); return; end %user cancel
fullname = fullfile(pathdir, file);
[fid, msg] = fopen(fullname, 'wt');
if fid < 0
error('Failed to open file "%s" because "%s"', fullname, msg);
end
fprintf(fid, '%s\n', Text);
fclose(fid);

类别

Help CenterFile Exchange 中查找有关 Dialog Boxes 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by