Linux下的matlab安装我就不多做解释了,网上的教程一大推,与windows不一样的是,不需要解压ISO,只需要直接装载(挂载)安装就行了,装完一个再挂载另外一个(建议一个挂载目录,建一个安装目录,matlab还算比较好装的,有的软件安装还需要离开本级目录进行命名,编译,运行的,卸载也是。。贼恶心),最后再激活,安装许可证就可以了。可以建立标准的快捷方式,不建立快捷方式的话,需要命令行进入matlab安装bin目录,去手动运行matlab启动程序。可能需要超级权限啥的,linux不同文件或者脚本运行的方式就那么几种,执行对应的命令运行对应的脚本就可以了,当然也会有一些快捷键,linux里充满了快捷键,但可能与windows略微有些不同。
使用Matlab运行Windows命令
可以使用Matlab的一些命令来帮助程序运行。比如说:
! calc % 打开计算器
! mspaint % 打开画图
dos calc % 打开计算器
比如一个程序要运行很长时间,而我们又不能一直守在计算机前,这时可以在程序运行完并保存好所需要的结果后在程序最后一行加上
! shutdown -s
则程序运行完毕后会自动关闭计算机。
matlab运行参数
matlab [-? ^| -h ^| -help]
[-c licensefile]
[-nosplash]
[-nodesktop ^| -nojvm]
[-memmgr manager ^| -check_malloc]
[-r MATLAB_command]
[-logfile log] [-timing]
[-noFigureWindows]
[-automation] [-regserver] [-unregserver]
-?^|-h^|-help - Display arguments. Do not start MATLAB.
-c licensefile - Set location of the license file that MATLAB
should use. It can have the form port@host.
The LM_LICENSE_FILE and MLM_LICENSE_FILE
environment variables will be ignored.
-nosplash - Do not display the splash screen during startup.
-nodesktop - Do not start the MATLAB desktop. Use V5 MATLAB
command window for commands. The Java virtual
machine will be started.
-nojvm - Shut off all Java support by not starting the
Java virtual machine. In particular the MATLAB
desktop will not be started.
-memmgr manager - Set MATLAB_MEM_MGR to manager.
manager - cache (default)
- fast for large models or MATLAB code
that uses many structure or
object variables. Is not helpful
for large arrays.
- debug does memory integrity checking.
Useful for debugging memory
problems caused by user mex files.
-check_malloc - same as '-memmgr debug'.
-r MATLAB_command - Start MATLAB and execute the MATLAB_command.
Any "M" file must be on the MATLAB path.
-logfile log - Make a copy of any output to the command window
in file log. This includes all crash reports.
-timing - Print a summary of startup time to the command
window. It is also recorded in a timing log,
the name of which is printed to the MATLAB
command window.
-noFigureWindows - Never display a figure window
-automation - Start MATLAB as an automation server,
minimized and without the MATLAB splash screen.
-regserver - Register MATLAB as a COM server
-unregserver - Remove MATLAB COM server registry entries.
转自:http://hi.baidu.com/wang1901/blog/item/764f1ff3f9ab7dce0a46e0c3.html
在Linux命令行下运行Matlab
参考:
https://blog.csdn.net/ws_20100/article/details/48492307
在Linux下安装完matlab后,会在/usr/local/bin/下生成matlab文件,可以使用matlab命令。
Usage: matlab [-h|-help] | [-n | -e]
[-arch | v=variant | v=arch/variant]
[-c licensefile] [-display Xdisplay | -nodisplay]
[-nosplash] [-mwvisual visualid] [-debug] [-softwareopengl]
[-desktop | -nodesktop | -nojvm]
[-r MATLAB_command] [-logfile log]
[-Ddebugger [options]]
-h|-help - Display arguments.
-n - Display final environment variables,
arguments, and other diagnostic
information. MATLAB is not run.
-e - Display ALL the environment variables and
their values to standard output. MATLAB
is not run. If the exit status is not
0 on return then the variables and values
may not be correct.
-arch - Start MATLAB assuming architecture arch.
v=variant - Start the version of MATLAB found
in bin/glnxa64/variant instead of bin/glnxa64.
v=arch/variant - Start the version of MATLAB found
in bin/arch/variant instead of bin/glnxa64.
-c licensefile - Set location of the license file that MATLAB
should use. It can have the form port@host or
be a colon separated list of license files.
The LM_LICENSE_FILE and MLM_LICENSE_FILE
environment variables will be ignored.
-display Xdisplay - Send X commands to X server display, Xdisplay.
-nodisplay - Do not display any X commands. The MATLAB
desktop will not be started. However, unless
-nojvm is also provided the Java virtual machine
will be started.
-nosplash - Do not display the splash screen during startup.
-mwvisual visualid - The default X visual to use for figure windows.
-debug - Provide debugging information especially for X
based problems.
-desktop - Allow the MATLAB desktop to be started by a
process without a controlling terminal. This is
usually a required command line argument when
attempting to start MATLAB from a window manager
menu or desktop icon.
-nodesktop - Do not start the MATLAB desktop. Use the current
terminal for commands. The Java virtual machine
will be started.
-singleCompThread - Limit MATLAB to a single computational thread.
By default, MATLAB makes use of the multithreading
capabilities of the computer on which it is running.
-nojvm - Shut off all Java support by not starting the
Java virtual machine. In particular the MATLAB
desktop will not be started.
-jdb [port] - Enable remote Java debugging on port (default 4444)
-r MATLAB_command - Start MATLAB and execute the MATLAB_command.
-logfile log - Make a copy of any output to the command window
in file log. This includes all crash reports.
-Ddebugger [options] - Start debugger to debug MATLAB.
-nouserjavapath - Ignore custom javaclasspath.txt and javalibrarypath.txt files.
在命令行下运行matlab,主要用到上面几个红色的参数。
1.直接运行Matlab
$ matlab
然后可以直接运行matlab脚本
2.运行m文件
如果m文件名为matlabfile.m
(1)方法一
进入m文件所在目录后,运行
$ matlab -nodesktop -nosplash -rmatlabfile
只用文件名matlabfile,不能添加.m
(2)修改.bashrc文件
$ vim ~/.bashrc
添加如下:
# Add an "mrun" alias for running matlab in the terminal.
alias mrun="matlab -nodesktop -nosplash -logfile `date +%Y_%m_%d-%H_%M_%S`.log -r"
保存后,进入.m文件所在目录,运行
$ mrun matlabfile
Sublime运行Matlab
参考:
https://blog.csdn.net/weixin_34122548/article/details/86340124
linux下的matlab是可以图形界面的,当然也可以不使用图形界面,毕竟linux系统都可以没有图形界面。。不过个人觉得,直观起见,还是尽量使用图形界面进行操作吧。
使用Sublime来作为Matlab的编辑器。Sublime编辑+Matlab命令行(terminal)运行的开发环境搭建。
前期准备
Matlab 2014a (Windows或Linux平台,这里以Win10和Ubuntu 16.04为例)。有关安装过程这里不再赘述。
Sublime Text 3
配置过程
- 新建Build System
在Sublime中选择Tools -> Build System -> New Build System,系统会创建一个JSON文件,根据不同系统输入以下内容:
Win10
{
"cmd": ["E:/Softwares/MATLAB/R2014a/bin/matlab.exe", "-nodesktop", "-nosplash", "-r", "\"run('$file')\""],
"selector": "source.m",
"working_dir": "${project_path:${folder}}"
}
Ubuntu 16.04
{
"cmd": ["gnome-terminal -x bash -c \"matlab -nosplash -nodesktop -r ${file_base_name}; exec bash\""],
"selector":"source.m",
"shell":"true",
"working_dir": "$file_path"
}
这些个编辑器,好像都是通过json文件来配置运行环境的,链接对应的运行程序即可,类似快捷方式。。
要注意cmd中对应的安装路径,这里给的路径是我的电脑中的配置。其中,matlab -nosplash -nodesktop -r ${file_base_name}表示启动matlab,并运行某个.m文件。-nosplash表示不加载启动界面;-nodesktop表示不加载GUI界面;-r表示运行Matlab命令行(MATLAB_command);file_base_name表示文件名,但不包含文件扩展名,如.m等。
【注】
这一步中有关Ubuntu的配置和网上一些教程有所区别,网上教程大多是没有gnome-terminal命令的。我这里希望以命令行方式启动Matlab。我在实践中发现,Sublime的Build
Results没有交互功能,只能显示运行结果。在Win10中Build时能自动打开Matlab命令行程序进行交互,但在Ubuntu中却没有打开命令行,所以在前面添加了启动终端(terminal)的相关命令,用于进行交互。
-
保存新建的Build System
命名并保存这个JSON文件到默认目录(这个JSON文件的名字将成为新的Build System的名字,出现在Build菜单中) -
通过Sublime启动MATLAB_command进行编译
设置完成。此时随便编辑一个.m文件,在Build System下选择刚新建的配置,点击Tools -> Build或者使用快捷键Ctrl+B,这时Sublime就会打开MATLAB_command并编译当前文件。
值得注意的是,每次Build都会产生一个新的命令行界面,相当于每次都重新启动了一次MATLAB_command,很耗费时间。所以建议在MATLAB_command启动后,每次修改了程序,先在Sublime中保存,然后在已有的控制台窗口输入脚本名进行编译。