Howdy!
How do I have to set up TextMate for using MATLAB? I have installed the MATLAB Bundle of Thomas Kjosmoen.
Is it now possible to compile MATLAB code directly out of TextMate without opening the code in the MATLAB editor?
Thanks!
Gewitterbukk wrote:
Is it now possible to compile MATLAB code directly out of TextMate without opening the code in the MATLAB editor?
I don't think the bundle provides any support for this, yet. Assuming we are talking about mcc, not embedded MATLAB, you should be able to invoke mcc in a terminal or via TextMate's run commands, though, and it should not be too hard to make the bundle learn that. (/Applications/MATLAB_R2009a.app/bin/mcc or something like that.)
I don't think any such option exists for embedded MATLAB. Once you find a way of running MATLAB code from TextMate, you can obviously do this: Just invoke the emlmex or mcc command, depending on which compilation you want.
Then again, it's rather unusual to compile MATLAB code before using/trying it inside MATLAB. For example, I don't think you have any chance of using an interactive debugger after compilation. And once you are inside MATLAB, yes, you can compile without firing up the editor. Just invoke the mcc or mex or emlmex command on the files.
Christopher
On 2009-April-26 , at 04:50 , Christopher Creutzig wrote:
Is it now possible to compile MATLAB code directly out of TextMate without opening the code in the MATLAB editor?
If by that you mention execute MATLAB code from within TextMate, here is the solution that I use:
As opposed to the previous poster, I don't like MATLAB's GUI very much. I find it slow and bulky. I tend to work in terminal by starting MATLAB this way: matlab -nosplash -nodesktop then I have a TextMate command to send the current selection or the current line to the frontmost Terminal window and then select the next line in the MATLAB (or any other language for that matter) source file, to which I assign a shortcut (such as ⌥↩). Now I can step line by line through MATLAB source by just pressing the shortcut repeatedly and see the result of the execution of the code in the Terminal, or send chunks of code at a time by selecting them and pressing the shortcut. The advantage of this method is that is works exactly the same whether your MATLAB session is running locally on your computer or on a server halfway around the world. This is a tremendous advantage for me since most of my MATLAB sessions are remote.
Here is the (very simple) command:
# input is selected text or line # output is discarded # scope is 'source'
# suppress tabs in the code that's sent to the Terminal (to avoid inappropriate shell expansion) rawText="$(cat | sed 's/ / /g;')"
# send the code to the Terminal osascript -e 'on run(theCode)' \ -e ' tell application "Terminal"' \ -e ' do script theCode in window 1' \ -e ' end tell' \ -e 'end run' -- "$rawText" # NB: depending in the delay to display this code in the terminal there can be some "collisions" between the lines of code sent. if the Terminal does not respond fast enough and you experience errors, try sending smaller chunks of code.
# step to the last character of the next line in TextMate open "txmt://open?line=$(($TM_LINE_NUMBER+1))&column=1000000" & # NB: if your selection goes all the way to the end of the last line (i.e. the selection color is visible beyond the last character, all the way to the the right border of the TextMate window), it means that the last line break is actually selected and the cursor is at the begining of the next line already. Stepping will move it one line down so it will appear to have stepped two lines. I don't know how to fix that yet.
I hope it may help.
JiHO --- http://jo.irisson.free.fr/