如何在Matlab中设置路径? [英] How to Set Path in Matlab?

查看:566
本文介绍了如何在Matlab中设置路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Matlab中为我的项目写了一些代码.这些代码包含一些功能和一个主运行文件,这些文件和脚本均单独编写并保存在一个文件夹中.当我要运行项目时,必须将 Matlab路径设置为此文件夹,然后运行主文件.

I wrote some codes for my project in Matlab. These codes consists of some functions and a main run file which are all scripted separately and kept in a folder. When I want to run the project I must set the Matlab path to this folder and then run the main file.

现在,我想在我的项目中使用由第三方开发的另一个工具箱.正如我所说,我想在自己的项目中使用此toolbox,但是我只能将Matlab路径设置为这些目录之一.我在想是否有办法将此工具箱添加到Matlab的主路径中,以便可以像Matlab的其他预定义功能(如fmincon)一样运行.

Now, I want to use another toolbox in my project which is developed by a third party. As I said, I want to use this toolbox in my own project, but I can only set the Matlab path to one of these directories. I was thinking if there is a way to add this toolbox to main path of Matlab so that it can be run like other predefined functions of Matlab like fmincon.

推荐答案

在使用工具箱的情况下,请将其添加到Matlab的主搜索路径中.您可以通过主面板中的设置路径来完成此操作:

In case of the toolbox I'd add it to the main search path of Matlab. You can do this with the Set Path in the main panel:

点击使用子文件夹添加,然后选择工具箱.

Click Add with Subfolders and choose the toolbox.

对于您的项目,我只需使用 addpath .此选项是临时的!如果您的文件夹包含您经常使用的一组功能,则也可以像上面一样使用设置路径"将其永久添加.但是请注意,如果其他人想使用您的项目,请将该文件夹传递给其他人.

For your project, I would add the folder to your main function simply by using addpath. This option is temporary! If your folder contains a set of functions you always use, you can also add it permanently as above with Set Path. But be aware to pass this folder to others, if they want to use your project.

这篇关于如何在Matlab中设置路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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