| MATLAB Function Reference | ![]() |
Syntax
genpath
genpath directory
p = genpath('directory')
Description
genpath 傳回以遞迴產生的 "在matlabroot/toolbox
底下的所有目錄的路徑" 的字串.
genpath directory 傳回以遞迴產生的
"在 directory
目錄底下的所有目錄的路徑" 的字串.
p = genpath('directory') 把傳回的路徑字串傳給變數p.
Examples
你可以用下面的命令得到一個字串包含 matlabroot\toolbox\images以及所有的其下的目錄:
p = genpath(fullfile(matlabroot,'toolbox','images'))
matlabroot\toolbox\images;matlabroot\toolbox\images\images; matlabroot\toolbox\images\images\ja;matlabroot\toolbox\images\ imdemos;matlabroot\toolbox\images\imdemos\ja;
你也可以將genpathaddpath 作連結,
可以得到從命令列將子目錄加入到路徑中. 下面的例子將 \control目錄加到它的目前路徑的子目錄裡.
% 秀出目前路徑
path
MATLABPATH
K:\toolbox\matlab\general
K:\toolbox\matlab\ops
K:\toolbox\matlab\lang
K:\toolbox\matlab\elmat
K:\toolbox\matlab\elfun
:
:
:
% 使用 GENPATH 將 \control 加入到它的子目錄中
addpath(genpath('K:\toolbox\control'))
% 秀出新的路徑
path
MATLABPATH
K:\toolbox\control
K:\toolbox\control\ctrlutil
K:\toolbox\control\control
K:\toolbox\control\ctrlguis
K:\toolbox\control\ctrldemos
K:\toolbox\matlab\general
K:\toolbox\matlab\ops
K:\toolbox\matlab\lang
K:\toolbox\matlab\elmat
K:\toolbox\matlab\elfun
:
:
:
See
Also
|
gco | get | ![]() |