如何访问MATLAB中的Windows相对路径(例如%userProfile%)



我想在matlab中获得一个相对路径(例如'c:/users/thisuser/thatfolder')。我在Unix机器上阅读了您可以使用的〜,但是我正在使用Windows系统。

有解决方法吗?感谢

您可以使用函数system

获得完整的路径

例如

[~,cmdout] = system('echo %APPDATA%')

应该给您完整的AppData路径。

您可以使用:

获得一般的Windows Env设置
userFolder = getenv ( 'userprofile' )

因此,要获得THATFOLDER使用:

fullfile ( userFolder, 'THATFOLDER' )

一行:

fullfile ( getenv ( 'userprofile' ), 'THATFOLDER' );

最新更新