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 个评论
回答(1 个)
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);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Dialog Boxes 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!