Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm learning matlab and using emacs to edit .m files. Is there a method in Emacs to call matlab to run programs?

share|improve this question
add comment

2 Answers

You can make MATLAB slurp in a .m file by feeding it to its standard input. In Emacs-speak, it is:

M-! matlab < foo.m

You might consider switching to Octave for this instead, however. Since GNU Octave is free like Emacs, you're going to find a lot more info out there about using the two together than for the non-free Matlab. Since Octave speaks much the same language as Matlab, it might be a complete replacement for your purposes.

One of the nice things you get by using Octave instead is that recent Emacsen know how to run Octave as an inferior process. This lets you have a window where you can type interactive commands and get feedback. This is very helpful while developing a more complex .m file.

Unlike MATLAB, Octave also knows how to behave like a proper Unixy scripting language. This lets you shorten the Emacs command above to:

M-! ./foo.m
share|improve this answer
add comment

Use the matlab major mode, or ocatve mode.

Either way, what you get is an interactive buffer where you can type matlab commands and get back results, as well as sending regions of text, entire function definitions, or whole files over to the running matlab process.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.