필터 지우기
필터 지우기

Problems with uiputfile

조회 수: 12 (최근 30일)
Daniel
Daniel 2011년 5월 17일
댓글: Mihir Tasgaonkar 2022년 6월 20일
I have a GUI that opens .txt or .xls file and then processes the file. I would like to allow the user the ability to save the results to a .txt and/or .xls file and to select the destination folder. I use 'uigetfile' to open my files. It works great! I am able to open and read both file formats. I am trying to use 'uiputfile' to save the results. This is where I am having trouble. The window opens, I type in the new file name and click save... but the file doesn't save. I can understand this part... I assume it should work similarly to uigetfile. I tried using 'xlswrite' after 'uiputfile.' The file saves but to the wrong(current) directory. I am unsure how to mesh the two commands. Any ideas?
Should I add a new directory? If so, how do I select which directory the file will be saved to?
Can I add the new path name to the xlswrite code to select the destination of the file?
Any help is greatly appreciated... Thanks!
  댓글 수: 1
Mihir Tasgaonkar
Mihir Tasgaonkar 2022년 6월 20일
Hi,
I'm developing a GUI that simulates a few systems and gives out graphs and values as results. I'm trying to generate a report at the end of the simulations with a "Save As" functionality.
[file,path]=uiputfile('*.*','Save As','Acceleration Test Results');
report=fullfile(path,file);
AccTestReport = Report(report,'pdf');
AccTestReport.OutputPath=path;
I tried doing this, but it doesn't save the PDF file anywhere. Any idea how I should proceed?

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

채택된 답변

Walter Roberson
Walter Roberson 2011년 5월 17일
[filename, pathname] = uiputfile(...);
fullname = fullfile(pathname,filename);
xlswrite(fullname, YourData);
  댓글 수: 1
Daniel
Daniel 2011년 5월 19일
Exactly what I was looking for... works great... Thank you!

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

추가 답변 (1개)

mb1400
mb1400 2013년 6월 24일
편집: Stefanie Schwarz 2022년 5월 5일
Thank you for the suggestion. I managed like this
[stmfile, stmpath] = uigetfile('*.txt', 'pick text file');
data = importdata(fullfile(stmpath, stmfile), '%s');
for opening
and
[filename, pathname] = uiputfile('*.txt','Save file name');
path_file=fullfile(pathname,filename);
fid=fopen(path_file,'wt');
for closing....

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by