How to get user homepath?

조회 수: 46 (최근 30일)
Wictor Oliveira
Wictor Oliveira 2022년 9월 1일
댓글: Wictor Oliveira 2022년 9월 6일
I want to get the user homepath in windows, the same as when I type '%homepath%' in the file explorer.
Example: 'C:\Users\USERNAME'
I am currently using this:
home_path = strrep(userpath,'Documents\MATLAB','')
but I'm afraid it might not work for all users depending on the way they installed matlab.
Is there a less 'hardcoded' way to get the user homepath in windows?

채택된 답변

Steven Lord
Steven Lord 2022년 9월 1일
Does getenv do what you want?
  댓글 수: 1
Wictor Oliveira
Wictor Oliveira 2022년 9월 6일
Thank you! That's an improvement.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by