简体   繁体   English

要通过Java / Matlab获取Matlab的保存路径?

[英]To get Matlab's Save Path by Java/Matlab?

I am trying to install WFDB Toolbox system-unspecifically in my systems (Ubuntu Linux 64bt/OS X El Capitan/Windows 10 education). 我正在尝试在我的系统中非特定地安装WFDB Toolbox系统(Ubuntu Linux 64bt / OS X El Capitan / Windows 10教育)。 I need to get the Matlab Path ie set in /usr/local/MATLAB/R2016a/toolbox/local/pathdef.m by Java/Matlab own means. 我需要获取Matlab路径,即通过Java / Matlab自己的方法在/usr/local/MATLAB/R2016a/toolbox/local/pathdef.m进行设置。 However, I did not find an approach for that. 但是,我没有找到解决方法。 Pseudocode 伪码

matlabpath=char(java.lang.System.getProperty('user.path'));

where I tried in path also matlabpath . 我在path中尝试过的地方也matlabpath

I have specific locations where I keep sufficient permissions for Matlab. 我在特定位置保留了对Matlab足够的权限。 I need the approach ie user.path such that I know where I need to keep sufficient privileges. 我需要这样的方法,即user.path,这样我知道我需要在哪里保留足够的特权。 Warning that I get when installing WFDB in Ubuntu Linux 64 bit and Matlab 2016a, which is a complication of not being able to manage the path non-system-specifically 警告在Ubuntu Linux 64位和Matlab 2016a中安装WFDB时出现警告,这是无法以非系统特定方式管理路径的复杂情况

Warning: Unable to save path to file '/usr/local/MATLAB/R2016a/toolbox/local/pathdef.m'. You
can save your path to a different location by calling SAVEPATH with an input argument that
specifies the full path. For MATLAB to use that path in future sessions, save the path to
'pathdef.m' in your MATLAB startup folder. 
> In savepath (line 169) 

Java would be the best solution for this, but Matlab's own solution is ok too. Java将是最好的解决方案,但是Matlab自己的解决方案也是可以的。


How can you get Matlab's path by Java/Matlab? 如何通过Java / Matlab获得Matlab的路径?

The "MATLAB Startup Folder" can mean many things depending upon the user's configuration as well as the operating system. 根据用户的配置和操作系统,“ MATLAB启动文件夹”可能具有许多含义。

The Mathworks has a whole page about this here . Mathworks 在这里有一个完整的页面。

One way is to ensure that the startup folder is the same as the userpath (how you do this depends on your OS so see the link above). 一种方法是确保启动文件夹与用户userpath相同(操作方式取决于您的操作系统,请参见上面的链接)。 Then you can access that from within MATLAB using the userpath command. 然后,您可以使用userpath命令从MATLAB中访问该userpath

folder = userpath

If you're on Linux, you can ensure that the userpath is used as the Startup Folder by following this excerpt from the link above. 如果您使用的是Linux,则可以通过遵循上面链接中的摘录,确保将用户userpath用作“启动文件夹”。

Default Folder on Linux Platforms Linux平台上的默认文件夹

On Linux® platforms, the default startup folder is the folder from which you started MATLAB. 在Linux®平台上,默认的启动文件夹是启动MATLAB的文件夹。

To specify the userpath as the startup folder, set the value of the environment variable MATLAB_USE_USERWORK to 1 before startup. 要将用户路径指定为启动文件夹,请在启动前将环境变量MATLAB_USE_USERWORK的值设置为1。 By default, userpath is userhome/Documents/MATLAB, and MATLAB automatically adds the userpath folder to the top of the search path upon startup. 默认情况下,用户路径为userhome / Documents / MATLAB,并且MATLAB在启动时会自动将用户路径文件夹添加到搜索路径的顶部。 To specify a different folder for userpath, and for other options, use the MATLAB userpath function. 要为用户路径和其他选项指定其他文件夹,请使用MATLAB用户路径函数。

There is another option (on newer versions of MATLAB) that would allow the user to set their startup path to whatever they want and you still be able to determine it. (在较新版本的MATLAB上)还有另一个选项,该选项使用户可以将启动路径设置为所需的路径,而您仍然可以确定它。

Since R2014b, users can specify the initial working path in the preferences ( MATLAB General -> Initial Working Folder ). 从R2014b开始,用户可以在首选项中指定初始工作路径( MATLAB General-> Initial Working Folder )。 You can check if the user has specified a custom initial working directory using the following commands 您可以使用以下命令检查用户是否已指定自定义初始工作目录

settings = Settings;
folder = settings.matlab.workingfolder.InitialWorkingFolder;

Disclaimer : This functionality was discovered by looking at MATLAB's own matlabrc file and while there is some documentation for Settings it's likely not officially supported, so use at your own risk. 免责声明 :此功能是通过查看MATLAB自己的matlabrc文件而发现的,尽管有一些 Settings文档,但它可能尚未得到正式支持,因此,后果自负。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM