Outdated egg!

This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.

If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.

  1. Outdated egg!
  2. matlab
    1. Example
    2. High-level API
    3. Low-level API
    4. License

This page is maintained in the this package's github repository.

matlab

This Chicken egg provides matlab bindings. It makes matlab somewhat bearable. See matlab-example.scm for how a quick example. Note that this egg doesn't at the moment deal well with Matlab errors and it currently only supports marshalling lists, vectors and matrices of doubles.

Example

  (matlab "'hello'")
  (matlab "a=2+2")
  (matlab-get-variable "a")
  (scheme->matlab! "a" '(3))
  (matlab-get-variable "a")
  (with-matlab-default-output-buffer
   (lambda (matlab-result-string)
    (matlab-eval-string "A=[[1,2,3];[4,5,6]]")
    (matlab-eval-string "B='Hi'")
    (matlab-eval-string "C=1")
    (matlab-show-variable "A")
    (matlab-show-variable "B")
    (matlab-show-variable "C")
    (matlab-eval-string "D=randn(2,2,2,2)")
    (display (matlab-result-string))
    (matlab-show-variable "D")
    (matlab-eval-string "'Can also get the output from matlab'")
    (display (matlab-result-string))
    (newline)))

This does a few random things in matlab to show off the API.

High-level API

[procedure] (matlab-eval-string s)
[procedure] (matlab-eval-strings . strings)
[procedure] (matlab . strings)

Execute one or more strings. (matlab . strings) returns the output of the command as a string. The return value of the other two calls is unspecified. These commands will start up an engine automatically if needed.

[procedure] (matlab-append-to-path directory)

Performs an addpath.

[procedure] (matlab-load-variables filename)
[procedure] (matlab-save-variables filename . variables)

Performs a load or a save. Saves the entire workspace if no variables are provided.

[procedure] (start-matlab!)

Starts the Matlab engine. Note that calling this function multiple times has no effect.

[procedure] (matlab->scheme variable-name)

Marshal a variable from Matlab to scheme. Only supports arrays and strings.

[procedure] (scheme->matlab! variable-name object)

Assign to a Matlab variable. Only supports matrices, vectors, and lists.

Low-level API

Many internal low-level functions for dealing with Matlab exist but they are of interest only to developers. Only those that may be of interest to users are listed here.

[procedure] (matlab-start arguments)
[procedure] (matlab-stop engine)

Start or stop an engine.

[procedure] (matlab-set-visible engine visible?)
[procedure] (matlab-get-visible engine visible?-pointer)

Get and set if the visibility of the Matlab UI.

[parameter] *default-matlab-engine-command*

The parameters to use when starting the global Matlab engine. Currently -nosplash -nodesktop. If you wish to add to these variables you can use the environment variable MATLAB_LOCAL_ARGS

[constant] *matlab-engine*

The current matlab engine.

License

Copyright 2013 Andrei Barbu. All rights reserved. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see http://www.gnu.org/licenses.