Access m-files in a subfolder without permanently adding it to the path

后端 未结 2 610
眼角桃花
眼角桃花 2020-11-27 22:26

I have downloaded a toolbox with many files in many subfolders (spatial-econometrics toolbox) for use on one particular project and I don\'t want to add it to the path becau

2条回答
  •  旧巷少年郎
    2020-11-27 22:50

    Add path to the top of MATLAB search paths for current MATLAB session only –

    addpath(PATHNAME)
    

    Same as addpath, but stays good for next sessions –

    savepath(PATHNAME)
    

    Add all subdirectories for current MATLAB session only -

    addpath(genpath(PATHNAME))
    

    Note: One must be careful while adding paths because if there are multiple function files with the same name, the one that is higher up on the path string, is chosen.

    More info here – addpath, savepath, genpath.

提交回复
热议问题