Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在寻找 matlab 内置函数来查找层次结构中存在的目录路径。例如:
path = c:\\temp\base\xyz\
path2 = matlabfunction (path)并返回c:\\temp\base
path2 = matlabfunction (path)
c:\\temp\base
尝试这个:
[a,b] = fileparts('C:\temp\base\xyz') a = C:\temp\base b = xyz
确保不要\在xyz,上包含尾随C:\temp\base\xyz\,否则它将包含xyz在返回的路径中。
\
xyz
C:\temp\base\xyz\
你可以试试
path2 = cd(cd([path '\..']));