How to let the matlab to remember the previous directory?

조회 수: 14 (최근 30일)
John
John 2014년 12월 18일
답변: John 2015년 1월 15일
I have this task daily:
Many plots are generated within the same "run". Then I check each of them. If it's good, I save it through "file" -> "save as".
However, for every save I need to choose the directory again. I wonder if I can setup matlab and let it to remember the last directory just seconds ago like many other software.
Thanks.

답변 (3개)

Scott Webster
Scott Webster 2014년 12월 18일
If you save your plots using a matlab command (e.g. print) then you can specify the path. You can also use a command like uiputfile to prompt the user for a filename etc...
pathname = 'C:\';
reply = input('Save plot? (y/n) (default n)','s');
if reply == 'y'
[plotfile,plotpath] = uiputfile('*.png','Select plot file name',pathname);
h=gcf;
plotfilepath=strcat(plotpath,plotfile);
print(h,'-noui','-r300','-dpng',plotfilepath);
end
  댓글 수: 1
Sean de Wolski
Sean de Wolski 2014년 12월 18일
Pretty sure you'll have to take this approach as I believe it's the OS that selects the starting directory for save.

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


John
John 2015년 1월 15일
When you "save", matlab always prompt the user interface for folders and file name. Instead of going to "default' directory, matlab should remember the last directory and goes to there, at least as an option like many other software.

Azzi Abdelmalek
Azzi Abdelmalek 2014년 12월 18일
Create a cell array where you can store your directories

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by