如何用不同的pathdef同时运行两个MATLAB实例? [英] How to run two MATLAB instances simultaneously with different pathdef's?

查看:136
本文介绍了如何用不同的pathdef同时运行两个MATLAB实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发我自己的大脑成像工具箱,它可以在MATLAB& SPM8,同时我有一个用于运行分析的我自己的工具箱代码目录(本地git存储库)的一个 d版本的git clone 'd版本,这个设置是根据Kevin创建的里德的答案在如何同时工作解决了一部分问题(如何让同一个 .m 文件的不同版本同时访问,并且仍然可以通过使用 git fetch git pull )进行同步。

然而,我的MATLAB安装不在这些git目录中;它通常安装在 / usr / local / MATLAB / R2012a / 中。 MATLAB根据 pathdef.m 查找函数,该函数存储在中,其中pathdef ( / usr / local / MATLAB / R2012a / toolbox / local / pathdef.m )作为常规函数。所以我不能同时运行两个MATLAB实例,以便它们具有不同的 pathdef ,至少不能修改 pathdef.m file。

当然,MATLAB必须事先知道在哪里寻找 pathdef.m 来定义路径。有没有办法改变 pathdef.m lookup path eg。通过一些MATLAB命令行参数或从MATLAB控制台?或者通过其他方法,以便我可以使用两个不同的 pathdef 同时运行两个MATLAB实例?或者我应该在两个不同的目录安装MATLAB?我对这个问题的各种解决方案感兴趣。 让我提供一种替代方法。它涉及创建快捷方式在MATLAB IDE中。



只需创建两个快捷方式,每个快捷方式都包含如下内容:

  addpath(genpath('/ path / to / project_branch'))%//将分支(和子文件夹)添加到MATLAB路径
cd('/ path / to / project_branch')%//导航到目录

(说明: addpath 不会保存系统范围内的更改,但会除非你打电话给 savepath



现在无论何时开始一个新的MATLAB会话,并且您决定在其中一个分支上工作,只需点击相应的快捷方式,并开始黑客入侵...

更好的是,如果你考虑一个分支为 stable ,另一个分支为 dev ,您可以永久地将稳定版本添加到路径中,并有选择地在路径 addpath('...',' - begin')的顶部添加开发版本c $ c>使用快捷方式,因此仅在当前会话中隐藏其他分支。




I'm developing my own brain imaging toolbox that runs under MATLAB & SPM8, and at the same time I have a git clone'd version of my own toolbox code directory (local git repository) for running analyses, this setup is created according to Kevin Reid's answer on How to work simultaneously on several different versions of files with git?, which solved a part of the problem (how to have different versions of same .m file accessible at the same time, and still synchronizable by using git fetch or git pull).

However, my MATLAB install is in neither of these git directories; it's installed normally in /usr/local/MATLAB/R2012a/. MATLAB looks for functions according to pathdef.m, which is stored in which pathdef (/usr/local/MATLAB/R2012a/toolbox/local/pathdef.m) as a regular function. So I cannot have two MATLAB instances running simultaneously so that they had different pathdef's, at least not by modifying pathdef.m file.

Of course MATLAB has to know beforehand where to look for pathdef.m to define the path. Is there a way to change pathdef.m lookup path eg. by some MATLAB command line argument or from MATLAB console? Or by some other means, so that I could have two MATLAB instances running simultaneously with different pathdef's? Or should I install MATLAB in two different directories? I'm interested in all kinds of solutions for this problem.

解决方案

Let me offer an alternative approach. It involves creating shortcuts inside the MATLAB IDE.

Simply create two shortcuts, each include something like:

addpath(genpath('/path/to/project_branch'))   %// add branch (and subfolders) to MATLAB path
cd('/path/to/project_branch')                 %// navigate to directory

(Explanation: The call to addpath will not save the changes system-wide, but will only persist for the current session, unless you call savepath)

Now whenever you start a new MATLAB session, and you decide to work on one or the other branch, simply click the corresponding shortcut and start hacking away...

Better yet, if you consider one branch as stable and the other as dev, you can add the stable one to the path permanently, and selectively add the development version on the top of the path addpath('...','-begin') using a shortcut, thus shadowing the other branch for the current session only.

这篇关于如何用不同的pathdef同时运行两个MATLAB实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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