_Matlab-interface_
==================
Requirements
------------
Matlab, c-compiler and plt-scheme.
The interface is written in ansi-c, to make it work in windows
and unix/linux.
Environment-Variables
---------------------
The environment-variables of c-compiler and matlab must be set
properly to make sure that:
(a) plt-scheme finds the c-compiler to compile and link the
matlab-interface.
(b) matlab-interface finds matlab to launch the matlab-engine.
Example-autoexec.bat:
PATH=%PATH%;c:\bin\matlab\bin\win32 <-- matlab
PATH=%PATH%;c:\cygwin\bin <-- gcc or ...
"CALL C:\PROGRA~1\MICROS~1\VC98\BIN\Vcvars32.bat" <-- ... msvc
Installation
------------
(1) Unpack the file 'matlab-interface.plt'.
(a) Put 'matlab-interface.plt' into the plt-directory .
(b) Either double-click on 'matlab-interface.plt'
or tell your shell:
cd
"Setup PLT" matlab-interface.plt
The directory /collects/matlab-interface/ is created and all
necessary files are put into it.
(2) Open 'info.ss' from /collects/matlab-interface/ in your
favourite editor.
Find your local matlab-installation and adjust the following
two values in 'info.ss' to your personal matlab-configuration:
(a) _matlab-include-directory_
--------------------------
'matlab-include-directory' is the complete path to the
directory that contains the file 'engine.h'.
The headerfile 'engine.h' is neccessary for successful
compilation of the matlab-interface and can be found
somewhere inside the matlab-directory.
(b) _matlab-link-libraries_
-----------------------
'matlab-link-libraries' is a list of complete paths to
the libraries that have to be linked with an object-file
to produce a matlab-engine-application.
These libraries are neccessary for successful linking of
the matlab-interface and can be found somewhere inside the
matlab-directory.
Save 'info.ss'.
(3) Launch MzScheme or DrScheme and type:
(require (lib "installer.ss" "matlab-interface"))
(install) ;; start compilation and linking
The file 'primitive.c' in /collects/matlab-interface/ is
compiled and linked to produce an extension-program which is put
inside /collects/matlab-interface/compiled/.
Usage - example
---------------
(require (lib "primitive.ss" "matlab-interface"))
(require (lib "highlevel.ss" "matlab-interface"))
(engine-open)
(display (engine-eval "magic (4)"))
(engine-close)
Better examples in directory collects/matlab-interface/examples/.
As I'm collecting more of them ... please contribute yours and I'll
include them in the next version.
Overview - definitions
----------------------
The matlab-interface supports low-level array-manipulation like
make-array, array-ref, array-set! and friends. Those are for the
ambitious user, who wants to build his own highlevel-procedures.
In general, you only need two types of functions: communicators and
converters:
- Communicators: engine-open, -close, -put, -get, -eval, -apply
- Converters to array: string->, object->, vector->, matrix->array
- Converters to scheme: array->string, ->object, ->vector, ->matrix
Engine-eval is easy to use in rapid interactive experimentation.
Engine-apply performs error-checking for use in robust applications.
Definitions in _primitive.ss_
-----------------------------
Load the definitions
(require (lib "primitive.ss" "matlab-interface"))
Abbreviations
vector of fixnums
vector of fixnums
symbol, one of '(cell char double int32)
default: 'double
symbol, one of '(real complex)
default: 'real
nested vectors, that implement multidimensional
array in scheme
Make Array
> (make-cell-array [object]) -> array
> (make-char-array [object]) -> array
> (make-array [type] [complexity] [object]) -> array
> (array-clone ) -> array
array-name -rank -size -shape -set! -ref and -fill!
> (array-name [string]) -> string
> (array-rank ) -> integer
> (array-size ) -> integer
> (array-shape ) -> shape
> (array-set! ) -> unspecified
> (array-ref value
> (array-fill!