Saving Path from uigetdir & showing files in uigetdir explorer.
4 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!