如何在终端中设置Matlab的用户路径? [英] How to Set up Matlab's userpath in Terminal?

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

问题描述

我想在终端中设置Matlab的userpath等,而不是在GUI Matlab会话中进行设置.

userpath('/home/masi/Documents/bin/matlab/')

该线程是线程该线程的连续2 关于startup.m,在这里我可以设置其他一些内容. 我在文档中找不到它,因此它必须在Matlab的未记录部分中,因为我知道可以完成此功能.

我在Suever回答后的建议

安装后仅运行一次

echo "export MATLAB_USE_USERWORK=1" >> $HOME/.bashrc

matlab -nodesktop -nosplash -r \ 
    "userpath('/home/masi/Documents/bin/matlab/'); exit;"

userpathaddpath

的问题

此处查看测试代码.其他一些配置也必须应用.

Matlab:2016a
系统:Linux Ubuntu 16.04

解决方案

在Linux上,startup.m文件应位于从命令行启动MATLAB时所在的文件夹中.

在Linux®平台上,默认的启动文件夹是启动MATLAB的文件夹.

如果要使用userpath作为启动文件夹而不是当前目录,则可以通过环境变量MATLAB_USE_USERWORK=1指定要使用userpath.默认情况下,它将指向$HOME/Documents/MATLAB(如果在MATLAB中设置,则为其他位置).

要将用户路径指定为启动文件夹,请在启动前将环境变量MATLAB_USE_USERWORK的值设置为1.默认情况下,userpath是userhome/Documents/MATLAB,并且MATLAB在启动时会自动将userpath文件夹添加到搜索路径的顶部.要为用户路径和其他选项指定其他文件夹,请使用MATLAB用户路径函数.

文档

请注意,如果您需要从终端运行MATLAB命令,则可以在没有UI的情况下运行MATLAB并执行必要的命令.

matlab -nodesktop -nosplash -r 'commands_here; exit;'

I want to set Matlab's userpath etc the following in Terminal, instead of doing it in GUI Matlab session.

userpath('/home/masi/Documents/bin/matlab/')

This thread is continua 2 of the thread How do I specify the MATLAB editor keybindings programmatically about startup.m where I can set some other things. I cannot find about it in Documentation so it must be in the undocumented part of Matlab because I know this feature can be done.

My proposal after Suever's answer

Run just once after the installation

echo "export MATLAB_USE_USERWORK=1" >> $HOME/.bashrc

matlab -nodesktop -nosplash -r \ 
    "userpath('/home/masi/Documents/bin/matlab/'); exit;"

Problem with userpath and addpath

See test codes here. Some other configurations have to be applied too.

Matlab: 2016a
System: Linux Ubuntu 16.04

解决方案

On Linux, the startup.m file should be located within the folder in which you were when you launched MATLAB from the command line.

On Linux® platforms, the default startup folder is the folder from which you started MATLAB.

If you want to use userpath as the startup folder instead of the current directory, you can specify that you'd like to use the userpath via the environment variable MATLAB_USE_USERWORK=1. This will by default point it at $HOME/Documents/MATLAB (or an alternate location if that was set within MATLAB).

To specify the userpath as the startup folder, set the value of the environment variable MATLAB_USE_USERWORK to 1 before startup. By default, userpath is userhome/Documents/MATLAB, and MATLAB automatically adds the userpath folder to the top of the search path upon startup. To specify a different folder for userpath, and for other options, use the MATLAB userpath function.

More info in the documentation

As a side note, if you need to run a MATLAB command from the terminal, it is possible to run MATLAB without the UI and have it execute the necessary command.

matlab -nodesktop -nosplash -r 'commands_here; exit;'

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

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