필터 지우기
필터 지우기

how to save a file into another folder by using uiputfile

조회 수: 15 (최근 30일)
Hello,
I have a matlab based programmatic gui. The user clicks on the save pushbutton. the pushbutton calls a callback function. The function creates the 'output.dat' file. Then, uiputfile asks the user where to save the .dat file. Everything so far is fine. However, I cannot save the file with the user specified name into the desired folder. I tried many functions such as copyfile, movefile,save but none worked. Can you help me please? Below there is an example function. It would also be nice to be able to save with the user specified format.
Thank you,
emre
fileID = fopen('output.dat','wt');
fprintf(fileID,'write something.');
[filename, pathname] = uiputfile('output.dat');
fclose(fileID);
save(filename,pathname,'f')

채택된 답변

Oleg Komarov
Oleg Komarov 2012년 8월 5일
편집: Oleg Komarov 2012년 8월 5일
If you can ask where to put it first then you can simply solve your problems with:
fileID = fopen('...\chosenDir\output.dat','wt');
i.e. you can write the file directly to the chosen directory.
You can selecet the directory first with uigetdir()
Alternatively you can move your file from one dir to another with movefile()
  댓글 수: 1
Seyhan Emre Gorucu
Seyhan Emre Gorucu 2012년 8월 6일
Thank you so much. My final code is this:
[filename, pathname] = uiputfile('output.dat');
path_file=fullfile(pathname,filename)
a=fopen(path_file,'wt');
fprintf(a,'write something.');
fclose('all')

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dialog Boxes에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by