I partially implemented a common lisp interface to matlab, re-using
the design of the R
package
R.matlab.
A server runs in the matlab process, and a connexion is stablished
from the lisp process. If the both run in the same machine, data is
transferred through the filesystem using .mat files.
Currently .mat files can be read, but not written; the following
fragment shows the basic functionality that is available (tested
only on Windows, using SBCL, CLISP, AllegroCL, and Lispworks).
> (with-open-stream (matlab (usocket:socket-stream
(usocket:socket-connect "localhost" 9999
:element-type '(unsigned-byte 8))))
(evaluate "magic=[2 7 6; 9 5 1; 4 3 8];" matlab)
(evaluate "eigenvalues=eig(magic);" matlab)
(read-matlab-file
(prog1 (get-variables '("magic" "eigenvalues") matlab)
(disconnect matlab))))
;; HEADER (text, subsys, version, endianess)
;; MATLAB 5.0 MAT-file, Platform: PCWIN, Created on: Thu Jul 10 22:55:03 2008
;;
;; #(1 0)
;; IM
;; DOUBLE-PRECISION
;; (3 3)
;; magic
;; (2 9 4 7 5 3 6 1 8)
;; DOUBLE-PRECISION
;; (3 1)
;; eigenvalues
;; (14.999999999999999D0 -4.898979485566356D0 4.898979485566356D0)
(#2A((2 9 4) (7 5 3) (6 1 8)) #2A((14.999999999999999D0) (-4.898979485566356D0) (4.898979485566356D0)))