matlab脚本编辑 [英] matlab script editing

查看:121
本文介绍了matlab脚本编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在两种情况下编辑matlab脚本



(1)在linux终端运行的matlab命令窗口中,如何创建和编辑脚本文件?使用

 编辑(文件名)

将调用交互式编辑器,这在Linux服务器上运行时不需要。



(2)在emacs中,有没有办法编写matlab脚本方便吗?哪个更好,使用MATLAB-Emacs或EmacsLink?



当我试图从 http://sourceforge.net/scm/?type=cvs&group_id=154105 ,我应该指定哪个模块名?



谢谢!






编辑:



安装MATLAB-emacs时,有一些问题。我以为我的CEDET安装在这里:

  / usr / share / emacs22 / site-lisp / cedet-common 
/ usr / share / emacs22 / site-lisp / cedet-contrib

我的CEDET是版本1: Ubuntu上的1.0pre4-3(intrepid)。所以我键入命令:

  $ makeLOADPATH = / usr / share / doc / cedet-common / usr / share / doc / cedet-contrib
for loadpath in。 / usr / share / doc / cedet-common / usr / share / doc / cedet-contrib; do \
echo(add-to-list'load-path \$ loadpath\)>>自动加载编译脚本; \
完成;
emacs-batch --no-site-file -l autoloads-compile-script -f cedet-batch-update-autoloads matlab-load.el。
Cedet-matlab.el的Generatim自动加载
cedet-matlab.el的生成自动加载完成
matlab.el ...的生成自动加载
Generatim自动加载为matlab.el ...完成
Generatim自动加载为mlint.el ...
Generatim自动加载mlint.el ...完成
Generatim自动加载语义matlab.el ...
语义matlab.el的Generatim自动加载完成
tlc.el的Generatim自动加载
tlc.el的完整自动加载完成
Generatim自动加载semanticdb-matlab.el ...
semanticdb-matlab.el的Generatim自动加载完成
更新头...
更新头...完成
写/ home /tim/.emacs.d/matlab-emacs/matlab-load.el
make:***没有规则使``lisp'需要的'matlab-publish.el'目标。停止。

有什么问题?谢谢!

解决方案

您应该注意,从版本R2009开始,EmacsLink已经从Matlab中删除,所以我会说在这Matlab-Emacs是一个更好的选择。 EmacsLink的主要优势在于更紧密和与Matlab集成,特别是在使用调试器时,但目前版本的Matlab-Emacs功能非常强大,并且可能满足大多数人的需求以及EmacsLink。



为了从Matlab调用Emacs,最简单的解决方案是运行Emacs服务器(M-x server-start)。然后可以将edit()命令设置为在Emacs中打开脚本。这里提供了有关如何执行此操作以及运行matlab-shell的详细说明:



http://blogs.mathworks.com/desktop/2009/09/14/matlab-关于CVS结帐:modulename是matlab-emacs。你以前能够下载一个档案,只需打包到你的elisp目录中。



编辑:我决定重新安装matlab-emacs;这是我做的一步一步。 (这些步骤很明显,但是这可能仍然是有用的,看看如何容易地遇到编译错误或误解某些指令)。请注意,在重新安装CEDET之前,matlab-emacs没有编译。



http://cedet.sourceforge.net/ (在我的情况下为1.0pre7)
将压缩文件压缩到〜/ .emacs.d / elisp /(现在有〜/ .emacs .d / elisp / cedet-1.0pre7 /目录)
通过编译CEDET make EMACS = / usr / bin / emacs
在〜/。 emacs.d / elisp,执行cvs checkout:

  cvs -z3 -d:pserver:anonymous@matlab-emacs.cvs .sourceforge.net:/ cvsroot / matlab-emacs co-matlab-emacs 

编译matlab-emacs通过

  makeLOADPATH = .. / cedet-1.0pre7 / common ../cedet-1.0pre7/eieio ../ cedet-1.0pre7 / semantic / bovine / ../cedet-1.0pre7/semantic/

理想情况一切都应该编译;现在是时候编辑启动文件:在.emacs中添加

 (setq load-path(cons〜/ .emacs。 d / elisp / matlab-emacs /load-path)
(load-librarymatlab-load)

matlab的startup.m 添加

  addpath('〜/ .emacs.d / elisp / matlab-emacs /工具箱, ' - 开始'); 
rehash;
emacsinit;

应该这样做!启动emacs,并做M-x matlab-shell。如果编辑foo.m不在emacs中打开foo.m,请确保服务器已启动(M-x server-start)。



为了最有效率,您可能希望找出对于从编辑缓冲区发送命令到matlab进程的工作(用模式中的快捷键进行实验)帮帮我)。最后,如果您需要调试东西,请在foo 中执行 dbstop,当您运行foo时,可以使用dbstop family命令(查找它们)或打开工具栏Mx工具栏模式),并使用按钮来控制断点,步进,继续等。完成后,键入dbquit。



不幸的是,如果你在Windows ,matlab-shell不是一个选项(这有点令人惊讶,看到我可以从命令行中几乎可以在太阳下运行一切 - Mathematica,R,numpy ...) - 所以你选择紧急emacs / matlab集成有点限制(除非你不介意运行支持emacslink的旧的matlab版本)。


I would like to edit matlab scripts in two cases

(1) In matlab Command window running in a linux terminal, how to create and edit a script file? use

edit(filename)

will invoke the interactive editor, which is not desired while operating on a linux server.

(2) In emacs, is there any way to edit matlab script conveniently? Which is better, using MATLAB-Emacs or EmacsLink?

when I am trying to cvs checkout MATLAB-Emacs from http://sourceforge.net/scm/?type=cvs&group_id=154105, which modulename should I specify?

Thanks!


EDIT:

When installing MATLAB-emacs, there is some problem. I thought my CEDET is installed here:

/usr/share/emacs22/site-lisp/cedet-common   
/usr/share/emacs22/site-lisp/cedet-contrib  

My CEDET is of version 1:1.0pre4-3 (intrepid) on Ubuntu. So I type the command:

$ make "LOADPATH=/usr/share/doc/cedet-common /usr/share/doc/cedet-contrib"    
 for loadpath in . /usr/share/doc/cedet-common /usr/share/doc/cedet-contrib; do \    
       echo "(add-to-list 'load-path \"$loadpath\")" >> autoloads-compile-script; \    
    done;    
 "emacs" -batch --no-site-file -l autoloads-compile-script -f cedet-batch-update-autoloads matlab-load.el .    
 Generatim autoloads for cedet-matlab.el...    
 Generatim autoloads for cedet-matlab.el...done    
 Generatim autoloads for matlab.el...    
 Generatim autoloads for matlab.el...done    
 Generatim autoloads for mlint.el...    
 Generatim autoloads for mlint.el...done    
 Generatim autoloads for semantic-matlab.el...    
 Generatim autoloads for semantic-matlab.el...done    
 Generatim autoloads for tlc.el...    
 Generatim autoloads for tlc.el...done    
 Generatim autoloads for semanticdb-matlab.el...    
 Generatim autoloads for semanticdb-matlab.el...done    
 Updatim header...    
 Updatim header...done    
 Wrote /home/tim/.emacs.d/matlab-emacs/matlab-load.el    
 make: *** No rule to make target `matlab-publish.el', needed by `lisp'.  Stop.    

What's wrong? Thanks!

解决方案

You should be aware that starting with version R2009a EmacsLink has been removed from Matlab, so I would say that at this point Matlab-Emacs is a better alternative. The main strength of EmacsLink was tighter and integration with Matlab, especially when using the debugger, but current version of Matlab-Emacs is quite capable and will probably satisfy most people's needs just as well as EmacsLink.

In order to invoke Emacs from Matlab, the cleanest solution is to run the Emacs server (M-x server-start). The edit() command can then be set up to open the script in Emacs. The detailed instructions on how to do this, as well as on running matlab-shell as inferior process are provided here:

http://blogs.mathworks.com/desktop/2009/09/14/matlab-emacs-integration-is-back/

Regarding CVS checkout: modulename is "matlab-emacs". You used to be able to download an archive and simply unpack into your elisp directory.

EDIT: I decided to reinstall matlab-emacs; here is a step-by-step of what I did. (The steps are pretty obvious, but this might still be useful seeing how it's easy to run into a compilation error or to misinterpret some instructions). Note that matlab-emacs didn't compile until I reinstalled CEDET.

Download CEDET from http://cedet.sourceforge.net/ (1.0pre7 in my case) Uncompress the archive into ~/.emacs.d/elisp/ (now have ~/.emacs.d/elisp/cedet-1.0pre7/ directory) Compile CEDET via make EMACS=/usr/bin/emacs While in ~/.emacs.d/elisp, do the cvs checkout:

cvs -z3 -d:pserver:anonymous@matlab-emacs.cvs.sourceforge.net:/cvsroot/matlab-emacs co -P matlab-emacs

Compile matlab-emacs via

make "LOADPATH=../cedet-1.0pre7/common ../cedet-1.0pre7/eieio ../cedet-1.0pre7/semantic/bovine/ ../cedet-1.0pre7/semantic/"

Ideally, everything should compile; now it's time to edit startup files: in the .emacs add

(setq load-path (cons "~/.emacs.d/elisp/matlab-emacs/" load-path))
(load-library "matlab-load")

and in matlab's startup.m add

addpath('~/.emacs.d/elisp/matlab-emacs/toolbox','-begin');
rehash;
emacsinit;

That should do it! Launch emacs, and do M-x matlab-shell. If edit foo.m doesn't open foo.m in emacs, make sure that the server has been launched (M-x server-start).

To be most productive, you might wish to figure out what works for you in terms of sending commands from the edit buffer to matlab process (experiment with the shortcuts in the mode help). Finally, if you need to debug stuff, do dbstop in foo, and when you run foo you can either use use dbstop family commands (look them up) or turn on toolbar (M-x tool-bar-mode) and use the buttons there to control breakpoints, stepping, continuing, etc. When finished, type dbquit.

Unfortunately, if you are on Windows, matlab-shell is not an option (which is a little surprising, seeing how I can run pretty much everything else under the sun from the command line -- Mathematica, R, numpy...) -- so your options for tight emacs/matlab integration are somewhat limited (unless you don't mind running an old matlab version that supports emacslink).

这篇关于matlab脚本编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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