在不将其永久添加到路径的情况下访问子文件夹中的m文件 [英] Access m-files in a subfolder without permanently adding it to the path

查看:71
本文介绍了在不将其永久添加到路径的情况下访问子文件夹中的m文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下载了一个工具箱,其中包含许多子文件夹中的许多文件(空间计量经济学工具箱)以供使用在一个特定的项目上,我不想将其添加到路径中,因为我不认为我会养成使用它的习惯,而且我也不知道它是否会隐藏统计信息工具箱中的函数.

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 because I don't think I'm going to make a habit of using it and I don't know if it's going to hide functions say in the stats toolbox.

如何访问此工具箱中的功能?是否有一种方法可以仅针对调用脚本的Matlab的特定会话以编程方式将其添加到路径中?解决这个问题的正确方法是什么?

How do I access the functions within this toolbox? Is there a way to maybe programatically add it to the path just for the particular session of Matlab that the script gets called in? What is the correct way to deal with this?

推荐答案

仅在当前MATLAB会话的MATLAB搜索路径顶部添加路径–

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

addpath(PATHNAME)

与addpath相同,但在下一个会话中保持良好状态–

Same as addpath, but stays good for next sessions –

savepath(PATHNAME)

仅添加当前MATLAB会话的所有子目录-

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.

这篇关于在不将其永久添加到路径的情况下访问子文件夹中的m文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆