used functions:
mfilename(): name of the current m-file
fileparts(): get the path string part
filesep: '/' or '\'
strfind(): find a substring from an objective string
code:
currentDepth = 1; % get the supper path of the current path
currPath = fileparts(mfilename('fullpath'));% get current
path
fsep = filesep;
pos_v = strfind(currPath,fsep);
p = currPath(1:pos_v(length(pos_v)-currentDepth+1)-1); % -1: delete
the last character '/' or '\'
阅读(1838) | 评论(0) | 转发(0) |