필터 지우기
필터 지우기

writetable, user defined name

조회 수: 6 (최근 30일)
Matthew Tyler Jeffries
Matthew Tyler Jeffries 2019년 3월 15일
댓글: Matthew Tyler Jeffries 2019년 3월 18일
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')

채택된 답변

Image Analyst
Image Analyst 2019년 3월 16일
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
Matthew Tyler Jeffries
Matthew Tyler Jeffries 2019년 3월 18일
Thank you! This is exactly what I needed!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by