This package solves the reverse problem of the Mathematica Symbolic Toolbox for MATLAB. (MathSource item 0205-951) That is, MaMa allows the Mathematica user to call MATLAB from within Mathematica. MaMa is implemented as a MathLink template program to talk to Mathematica and uses MATLAB's engine interface to talk to MATLAB. MaMa must be compiled on the same platform on which you run MATLAB and this must be a Unix platform since MATLAB's engine interface only exists on Unix. However, since MathLink can connect heterogeneous platforms, you can call MaMa from any MathLink-capable copy of Mathematica. For example, if you have MATLAB on a Sun build MaMa there. Now you can call MaMa from Mathematica running on any Unix, Macintosh, or Microsoft Windows machine. These are the pieces needed to run Matlab under Mathematica: Files:____________________________________________________ Makefile -- Obvious MaMa.tm -- Templates MaMa.c -- C-code MaMa.m -- A file with stuff that could have been in the MaMa.tm file, but editing and experimenting is so much faster with an m-file. Commands:_________________________________________________ MOpen[] -- Open a connection to Matlab process MClose[] -- Close ditto MEvaluate[ "cmd" ] (or M[ "cmd" ] for short) -- Evaluate an expression verbatim in the Matlab environment MBegin[] -- Start a Matlab mode. This means that every string is evaluated in the Matlab environment MEnd[] -- Close the Matlab mode. MPutMatrix[ "name", expr ] -- Evaluate expression and translate to a Matlab matrix. Then assign name to this matrix MGetMatrix[ "name" ] -- Get a Matlab matrix to the Mathematica environment Comments:_________________________________________________ o I use MClose/MOpen, becuase eventually we should be able to run remote and also run several Matlab processes under this Mathematica process. o I really wanted the Mathematica mode to only use the Matlab parser, i.e. everything should be sent directly to Matlab except MEnd[]. (I have not suceeded in sypplying my own parser despite substantial number of trials with $PreRead, $Pre, $Post and $SyntaxHandler ... if you have any ideas they are certainly welcome.) Examples:___________________________________________________ Mathematica 2.2 for SPARC Copyright 1988-93 Wolfram Research, Inc. -- Open Look graphics initialized -- In[1]:= < {0.25, 0.2, 0.166666666666667}} (* Start a Matlab mode *) In[7]:= MBegin[] (* Every string is sent to the Matlab evaluator *) MatlabIn[8]:= "[1,2; 3,4]" MatlabOut[8]= ans = 1 2 3 4 MatlabIn[9]:= "m = rand(3,3)" MatlabOut[9]= m = 0.0077 0.4175 0.9304 0.3834 0.6868 0.8462 0.0668 0.5890 0.5269 MatlabIn[10]:= "inv(m)" MatlabOut[10]= ans = -1.2923 3.1057 -2.7054 -1.3774 -0.5504 3.3160 1.7035 0.2213 -1.4655 (* Return to the standard Mathematica evaluator *) MatlabIn[11]:= MEnd[] (* I.e. strings are no longer evaluated by Matlab ... *) In[12]:= "m = [1,2;3,4]" Out[12]= m = [1,2;3,4] (* ... unless you really want them to! *) In[13]:= M[ % ] Out[13]= m = 1 2 3 4 ------------------------------------------------- ! From: Roger Germundsson ! ! Dept. of Electrical Engineering ! ! Div. of Automatic Control ! ! Linkoping University ! ! S-581 83 Linkoping, Sweden ! ! ! ! Phone: (46) 13 282704 ! ! Fax: (46) 13 139282 ! ! Email: roger@isy.liu.se ! -------------------------------------------------