필터 지우기
필터 지우기

Saving Path from uigetdir & showing files in uigetdir explorer.

조회 수: 5 (최근 30일)
Adam Conover
Adam Conover 2017년 7월 21일
답변: Kambren Rowlan 2017년 7월 21일
I have a popup menu with three cases; A, B, C. The cases set a file path for the function. A & B are hardcoded, but C uses UIGETDIR to allow the user to set their own file path.
1) UIGETDIR only shows folders, is it possible to display files in the explorer?
2) Upon selecting a file path using UIGETDIR, I'd like the user to have to option to save that file path for future use and have it displayed in the popup menu. - User selects filepath - "Would you like to save this filepath?" - No -> continue on - Yes -> "Set Name" -> filepath under "Name" is saved to popup menu.
Don't know if 2) is possible, but any help would be great.

답변 (1개)

Kambren Rowlan
Kambren Rowlan 2017년 7월 21일
I think this may help with your 2nd question. Saves the pathname as a workspace variable, then loads it in on request, might not be the most elegant solution but I think it's capable of getting done what you're trying if you adapt it.
user_input = input('Which default path: ');
switch user_input
case 1
%input 1 to use saved path
load userPath.mat;
startingPoint = PathName;
case 2
%hardcoded
startingPoint = '';
case 3
%hardcded
startingPoint = '';
otherwise
error('invalid input')
end
[PathName] = uigetdir(startingPoint,'Select a Directory');
user_input2 = input('Would you like to save your selection: ');
%input 1 to save path
if user_input2 == 1
save('userPath.mat','PathName');
end

카테고리

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