How to save a txt file through gui app designer ?

12 Ansichten (letzte 30 Tage)
Priyadarshan Priyadarshan
Priyadarshan Priyadarshan am 24 Feb. 2022
Beantwortet: Kojiro Saito am 25 Feb. 2022
So my gui has a button Generate. The idea is to create a txt file when user clicks on it. I am not able to assess how should I do that?

Antworten (1)

Kojiro Saito
Kojiro Saito am 25 Feb. 2022
For creating .txt files, there are various ways including save (with '-ascii' option), writatable, writematrix, writecell and fopen (with 'w' option) so on.
And with uiputfile, users can choose where to save .txt files.
Here is a sample in Button pushed callback function.
% Button pushed function: GenerateButton
function GenerateButtonPushed(app, event)
p = rand(1,10);
[file,path] = uiputfile('out.txt');
save(fullfile(path, file), 'p', '-ascii')
end

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by