Borrar filtros
Borrar filtros

writetable, user defined name

6 visualizaciones (últimos 30 días)
Matthew Tyler Jeffries
Matthew Tyler Jeffries el 15 de Mzo. de 2019
Comentada: Matthew Tyler Jeffries el 18 de Mzo. de 2019
I have a code that generates a txt file by using the function writetable (shown below). In my code, I name the file 'final.txt'. However, I would like the user to be prompted to enter the name of the file while the code is running so that the file can be saved according to the users entered file name.
writetable(Results_Table,'final.txt','Delimiter','\t')

Respuesta aceptada

Image Analyst
Image Analyst el 16 de Mzo. de 2019
Use this code:
% Get the name of the file that the user wants to save.
startingFolder = userpath % Or "pwd" or 'C:\my results' or wherever you want.
defaultFileName = fullfile(startingFolder, '*.txt');
[baseFileName, folder] = uiputfile(defaultFileName, 'Specify a file');
if baseFileName == 0
% User clicked the Cancel button.
return;
end
fullFileName = fullfile(folder, baseFileName)
writetable(Results_Table, fullFileName, 'Delimiter', '\t')
  1 comentario
Matthew Tyler Jeffries
Matthew Tyler Jeffries el 18 de Mzo. de 2019
Thank you! This is exactly what I needed!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by