Matlab Mode Help
Name:Matlab Mode
Version:3.1
Last update:2019-11-27 14:13:00





This help file describes the MATL (Matlab) mode. MATLAB is an integrated technical computing environment that combines numeric computation, advanced graphics and visualization, and a high-level programming language. MATLAB is a commercial product available at https://www.mathworks.com/.
This package allows Alpha to act as a front end for MATLAB for Macintosh version 5.0 or higher. Some features will work with MATLAB 4.2c, but you should upgrade to MATLAB 5 to avoid a serious bug in MATLAB 4.2c as described below. As of this writing, there has been no known testing of this mode with MATLAB version 6.5.1 (or greater) in Mac OS X.

Main Features

A Matlab Example syntax file is available for exploring the MATLAB mode's features and menu.

Editing matlab files

If you open any text file with a .m extension, Alpha will normally recognize it as a MATLAB file and set the current mode to be MATL. There may be a conflict though with Objective C files which also use the .m extension. You can fix this using the Alpha ↣ Global Setup ↣ Preferred Mapping… menu item.
You type in your MATLAB code as you normally would, but Matlab Mode helps you in several ways. It will color certain key words. You can easily change the coloring scheme in the Alpha ↣ Mode Setup ↣ Mode Preferences… menu item. Click here to open the MATL Mode Preferences.
As you type you may notice some strange (but very useful!) behavior. If you hit return, the next line will be automatically indented for you according to the previous lines indentation and the block structure. You can turn off this feature by unselecting Indent On Return in the mode flags. In addition if you type a Semicolon ";", Matlab Mode will automatically hit return for you. You can turn off this feature by unselecting Electric Semicolon in the mode flags.
The Matlab mode provides a console that lets you communicate with a matlab interpreter and execute code interactively.
Once you are finished editing a MATLAB file, you can also select the Save And Execute command from the MATLAB menu to send the file to MATLAB for execution via the console. The results will be shown in the console window within Alpha. If you only want to execute part of the file simply select the code you want and then choose Execute Selection from the MATLAB menu.
If there is a matlab file in your code that you wish to edit, you can easily open it in several ways. One is to select the name and then choose Open Selection from the MATLAB menu. Another way is to press the Shift-Command modifiers (⇧⌘) and then Double-Click on the matlab command. This will bring up help on that command.

Console window

This acts similar to the command window in MATLAB. Simply type in a command at the prompt and hit return to have it executed by MATLAB. Use the Up and Down Arrow keys to recall previous commands. Hit Control-U to cancel the current line.

Command history window

This acts similar to the history window in MATLAB: it contains a list of all previous commands entered in the command window. Commands sent from m-files are not added. Use the arrow Keys to navigate Up or Down and press Return to reissue the command. TNot that the console communicates with a matlab process via an interactive pipe and not with the MATLAB application itself, so the Matlab application do not have to be running for the console to work.

Shift-Command-Double-Clicking

Press the Shift-Command modifiers (⇧⌘) and Double-Click on a Matlab command. This will bring up help on that command.

Matlab Menu Items

Matlab Menu

Switch To Matlab
Swap the process to the Matlab GUI application, launching it if necessary.
Launch Console
Open Alpha's own console to communicate with a matlab process and execute commands interactively from within Alpha.
Command History
Open a history window.
Execute Selection
Execute selection via Alpha's Matlab console; if nothing is selected execute current line.
Save And Execute
Save and execute current window.
Open Selection
Open m-files of selection.
Get Help…
Presents a dialog box for entering in a command to ask MATLAB for help on.
Help For Selection
Get help on selected command in current window.

Workspace Menu

Rebuild Path
Sends a "path(path)" to MATLAB.
Add To Path
Get the path of current window and add it to MATLAB's path.
Cd To Win
Set current directory to the folder of the current window.
Clear Workspace
Sends a "clear" to MATLAB.
Clear Procedure
Removes current window's function from the workspace ("clear m-file").
Close All
Closes all MATLAB figure windows ("close all")

Non-Menu Key Bindings

All windows

Options-;Electric semicolon with jump to next stop

Command Window Only

ReturnExecute current command line in Matlab
Up-ArrowRecall Previous Command
Down-ArrowRecall Next Command
⌃UCancel Line

m-files Window Only

⌃-ReturnExecute current line in Matlab

Electric Completions

MATL supports Electric Completions for switch, while, and for.

Customization

Here are some things you can set via the Alpha ↣ Mode Setup ↣ Mode Preferences… menu item:
  1. Toggle the behavior of ⌘Double Clicking.
  2. Set the color of the different kinds of keywords.
  3. Turn off electric semicolon.
  4. Turn off auto-indentation (elecReturn).
  5. Turn off warning that Matlab is busy (queEventsQuietly).
  6. Use web browser to view help files or use normal Matlab help.
  7. Automatically send a clear function command to Matlab when saving a file.
Click here to open the MATL Mode Preferences.
In addition, you can simply add items to the matlab menu in a MATLPrefs.tcl file, without having to modify matlabMode.tcl. Here is an example:
    menuItem append $MATL::menuToken(main) "-"
    menuItem append $MATL::menuToken(main) "stephen" -command matDummyMenuItem
You then define the proc (called matDummyMenuItem in this example) associated to the new menu item:
    proc matDummyMenuItem {} {text insert "Smart guy"}

Known problems

Please report any problem or bug you encounter in Alpha's Bug Tracker.

License and Disclaimer

Copyright (c) 1995-2019, Stephen Merkowitz.
All rights reserved.
The Matlab Mode package is free software and distributed under the terms of the new BSD license:
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STEPHEN MERKOWITZ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.