MATLAB: How to get only foldername with uigetdir

functionMATLABname of folderuigetdir

Hello, I want to select a folder (would be subfolder2 in my example) and use its name as a string. The problem is that not only the foldername but the whole location is the output of uigetdir().
name = uigetdir('./subfolder1/');
Is there a simple function to just get the name of the selected folder?
Cheers, J

Best Answer

filepath = uigetdir('./subfolder1/');
[~,name] = fileparts(fileparts)