필터 지우기
필터 지우기

How to get only foldername with uigetdir

조회 수: 94 (최근 30일)
Jonas K
Jonas K 2017년 6월 27일
댓글: Stephen23 2022년 3월 23일
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
  댓글 수: 1
Guillaume
Guillaume 2017년 6월 27일
But what if the user navigate to a completely different folder? Maybe not even on the same drive?

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

채택된 답변

Stephen23
Stephen23 2017년 6월 27일
편집: Stephen23 2022년 3월 23일
fp = uigetdir('./subfolder1/');
[~,name] = fileparts(fp)
  댓글 수: 3
Carl Hopkins
Carl Hopkins 2022년 3월 23일
change second line of text to:
[~name]=fileparts(filepath)
Stephen23
Stephen23 2022년 3월 23일
@Carl Hopkins: fixed, thank you.

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

추가 답변 (0개)

카테고리

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