10.5 安装MATLAB®

Contributed by Dan Pelleg.

  这一节描述在一个 FreeBSD 上安装Linux版本的MATLAB® version 6.5。 它工作的很好,除了Java Virtual Machine例外(参考 第 10.5.3 节)。

  Linux版本的MATLAB可以从MathWorkshttp://www.mathworks.com订购。请确定您也得到了许可文件或安装说明。 等您成功后,让他们知道您想要一个本地FreeBSD版本。

10.5.1 安装MATLAB

  请按照下面的步骤安装MATLAB

  1. root身份插入安装CD并挂载上。 推荐使用安装脚本,为了启动安装脚本,键入:

    # /compat/linux/bin/sh /cdrom/install
    

    提示: 安装程序是图形的。如果您得到不能打开显示的错误,可以键入 setenv HOME ~USERUSER是您su(1)成的用户。

  2. 当问MATLAB的根目录时,键入: /compat/linux/usr/local/matlab

    提示: 为了下面的安装过程更方便,在shell提示符下键入 set MATLAB=/compat/linux/usr/local/matlab

  3. 根据获得MATLAB许可时的指示来编辑许可文件。

    提示: 您可以用您喜欢的编辑器提前准备这个文件, 并在安装程序要您编辑它之前复制到 $MATLAB/license.dat

  4. 完成安装过程

  到这里,您的MATLAB安装已经完成了。 接下来的步骤是让它和您的FreeBSD 系统“胶合”在一起。

10.5.2 许可管理器的启动

  1. 为许可管理器建立符号链接的脚本:

    # ln -s $MATLAB/etc/lmboot /usr/local/etc/lmboot_TMW
    # ln -s $MATLAB/etc/lmdown /usr/local/etc/lmdown_TMW
    
  2. 建立启动文件/usr/local/etc/rc.d/flexlm.sh。 下面的例子是一个$MATLAB/etc/rc.lm.glnx86的修改版本。 变化的是文件的位置,和模拟Linux下许可管理器的启动。

    #!/bin/sh
    case "$1" in
      start)
            if [ -f /usr/local/etc/lmboot_TMW ]; then
                  /compat/linux/bin/sh /usr/local/etc/lmboot_TMW -u username && echo 'MATLAB_lmgrd'
            fi
            ;;
      stop)
        if [ -f /usr/local/etc/lmdown_TMW ]; then
                /compat/linux/bin/sh /usr/local/etc/lmdown_TMW  > /dev/null 2>&1
        fi
            ;;
      *)
        echo "Usage: $0 {start|stop}"
        exit 1
        ;;
    esac
    
    exit 0
    

    重要: 必须使脚本文件可执行:

    # chmod +x /usr/local/etc/rc.d/flexlm.sh
    

    您也必须替换username为机器上的一个用户(不要是root)。

  3. 用命令启动许可管理器:

    # /usr/local/etc/rc.d/flexlm.sh start
    

10.5.3 链接Java™运行时环境

  改变Java运行时环境(JRE),链接到一个可以工作的版本:

# cd $MATLAB/sys/java/jre/glnx86/
# unlink jre; ln -s ./jre1.1.8 ./jre

10.5.4 创建MATLAB启动脚本

  1. 把下面的启动脚本放到/usr/local/bin/matlab

    #!/bin/sh
    /compat/linux/bin/sh /compat/linux/usr/local/matlab/bin/matlab "$@"
    
  2. 然后输入命令chmod +x /usr/local/bin/matlab

提示: 依赖于您的emulators/linux_base版本, 您在运行这个脚本时可能会出错,为了避免错误,编辑/compat/linux/usr/local/matlab/bin/matlab, 把这行:

if [ `expr "$lscmd" : '.*->.*'` -ne 0 ]; then

(在13.0.1版本是在第410行)改成:

if test -L $newbase; then

10.5.5 Creating a MATLAB Shutdown Script

  The following is needed to solve a problem with MATLAB not exiting correctly.

  1. Create a file $MATLAB/toolbox/local/finish.m, and in it put the single line:

    ! $MATLAB/bin/finish.sh
    

    注意: The $MATLAB is literal.

    提示: In the same directory, you will find the files finishsav.m and finishdlg.m, which let you save your workspace before quitting. If you use either of them, insert the line above immediately after the save command.

  2. Create a file $MATLAB/bin/finish.sh, which will contain the following:

    #!/usr/compat/linux/bin/sh
    (sleep 5; killall -1 matlab_helper) &
    exit 0
    
  3. Make the file executable:

    # chmod +x $MATLAB/bin/finish.sh
    

10.5.6 使用MATLAB

  现在您已经可以键入 matlab 并开始使用它了。

本文档和其它文档可从这里下载:ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/.

如果对于FreeBSD有问题,请先阅读文档,如不能解决再联系<questions@FreeBSD.org>.
关于本文档的问题请发信联系 <doc@FreeBSD.org>.