Matlab
The software provided on this page has been tested with Matlab version 5, and 6 on HP-UX, Solaris, Linux, and Windows (MinGW) and Matlab version 7 on Windows.
A history of my Matlab Central File Exchange submissions can be found here.
• Matlab Widget Toolkit: | ||
• Parse Command Options: | ||
• Rubber-Band Selection: | ||
• Text File Printing: | ||
• Configuration Utilities: | ||
• Directory Stack: |
Next: Parse Command Options, Up: Matlab
Matlab Widget Toolkit
MTk is a high-level command line interface for creating graphical user interfaces using Handle Graphics. MTk is for people who don’t need a guide to write graphical user interfaces.
Below is the code of MTk’s Tab Panel demo. As you can see, only three commands are needed to build a whole GUI.
f = mtk('figure', 0, '0x0', ... 'Name', 'MTk Demo: Tab Panel', ... 'Resize', 'off', ... 'Visible', 'off'); mtk('render', f, ... {'vbox' ... 'Margin' 16 ... 'Padding' 16 ... {'tabs' ... {'tab' ... 'Caption' 'First' ... {'vbox' ... 'Margin' 8 ... {'text' ... 'String' 'Hello world!'}}} ... {'tab' ... 'Caption' 'Second' ... {'vbox' ... 'Margin' 8 ... {'text' ... 'String' 'Good by sailor!'}}} ... {'tab' ... 'Caption' 'Third' ... {'box' ... 'Margin' 8 ... {'tabs' ... {'tab' ... 'Caption' 'Fourth' ... {'vbox' ... 'Margin' 8 ... {'group' ... 'Caption' 'Fruits:' ... {'vbox' ... 'Margin' 8 ... {'checkbox' ... 'String' 'Apples'} ... {'checkbox' ... 'String' 'Bananas'}}}}} ... {'tab' ... 'Caption' 'Fifth' ... {'vbox' ... 'Margin' 8 ... {'text' ... 'String' 'The end.'}}}}}}} ... {'hbox' ... 'Pack' 'center' ... {'pushbutton' ... 'String' 'Close' ... 'Callback' 'delete(gcbf);'}}}); set(f, 'Visible', 'on');
Here is the result. Isn’t that nice.
Next: Rubber-Band Selection, Previous: Matlab Widget Toolkit, Up: Matlab
Parse Command Options
The getopt
command parses options from an argument list. The aim
is to be close to GNU long options functionality, and beyond.
Here is an example, for how to use getopt
.
function foo(varargin) % Initialize options. opt = getopt(5); for ind = 1:numel(opt) switch ind case 1 opt(ind).name = '-flag'; opt(ind).type = 'flag'; case 2 opt(ind).name = '-mode'; opt(ind).type = 'char'; opt(ind).choices = {'box', 'line'}; opt(ind).values = [4, 2]; opt(ind).value = 4; opt(ind).assign = 1; case 3 opt(ind).name = '-color'; opt(ind).type = 'color'; case 4 opt(ind).name = '-cursor'; opt(ind).type = 'cursor'; case 5 opt(ind).name = '-fullcross'; opt(ind).type = 'alias'; opt(ind).index = 4; opt(ind).value = 'fullcrosshair'; otherwise error('Should not happen'); end end % Parse options from argument list. [opt, arg] = getopt(opt, varargin{:});
Next: Text File Printing, Previous: Parse Command Options, Up: Matlab
Rubber-Band Selection
Select a figure or axes region.
This rubber-band command has a lot of customization options, for example, rubber-band mode (box, x, y, line), optional display of cursor coordinates, free selection of color, line style, marker symbol, and figure cursor, axes expansion, choice of return values (points, vectors, rectangle), and the type of rendering for animated objects.
The rubberband
command depends on the getopt
command (see
above).
Here is an example for how to it.
x = linspace(0, 2 * pi); subplot(2, 1, 1); plot(x, sin(x)); axis tight; subplot(2, 1, 2); plot(x, cos(x)); axis tight; [p1, p2] = rubberband('-mode=x', '-coord', '-expand=y');
Next: Configuration Utilities, Previous: Rubber-Band Selection, Up: Matlab
Text File Printing
Convert text file for printing.
The textpr
command converts a text file for printing. Paper
size, page layout, n-up printing, basic formatting, and output file
format can be customized via command line options.
The textpr
command depends on the getopt
command (see
above) and a Ghostscript executable (like the one shipped with older
versions of Matlab).
Next: Directory Stack, Previous: Text File Printing, Up: Matlab
Configuration Utilities
The m-config
package provides GNU Autoconf macros checking
for Matlab features and platform incompatibilities. Documentation and a
complete example project are included in the package.
See the Matlab Configuration Utilities manual, for more details.
m-config
is free software and distributed under the GNU
General Public License.
Previous: Configuration Utilities, Up: Matlab
Directory Stack
The m-dirs
package provides the directory stack commands as known
from various Unix shells for Matlab. Available Matlab commands are
dirs
, pushd
, and popd
.
Command names and usage is equal to the Unix shell commands:
>> pwd ans = /tmp >> pushd /usr/bin /usr/bin /tmp >> pwd ans = /usr/bin >> popd /tmp >> pwd ans = /tmp
m-dirs
is free software and distributed under the GNU
General Public License.