A symbolic toolbox that provides MATLAB users with all of the symbolic and highprecision numeric capabilities of Mathematica. It uses the MathLink communication standard supplied with Mathematica and the MEX facility of MATLAB. In addition, since MathLink can pass native MATLAB matrices (and not just strings) between Mathematica and MATLAB, it is quick and easy to construct matrices in either system and pass them to the other. One can freely mix Mathematica code and MATLAB code without the bother of writing Mfiles to convert matrices into strings and back. The Mathematica Symbolic Toolbox for MATLAB is implemented as a single MEXfile and the source code is included. Precompiled linux and windows executables are included. Installation instructions for MACs are included in the README.Version 2.0 has been updated from:http://library.wolfram.com/infocenter/MathSource/624 to work with MATLAB R2007b and Mathematica 6.0.
1.2.0.0  Removed mex file 

1.1.0.0  updated to work with mathematica 7 

1.0.0.0  Slight update for windows users. 

Doc update. New binary. Recompiled to work with most recent versions. 

Documentation link fix. 

better windows support 

better windows support 

Better packaging. 

Updated with MAC installation instructions. 

updated help for windows users 

Now including windows dll. Updated description. 

Title should be 2.0, slightly updated mex file and README file. 
Create scripts with code, output, and formatted text in a single executable document.
Lee Yongsheng (view profile)
I've managed to install this toolbox both on Win7 and Ubuntu 18.04 LTS, for Mathematica 11.2 and MATLAB R2017b. Thanks Ben Barrowers, it works very well on Win7. But I found a problem on my Ubuntu, i.e. , the process "WolframKernel" launched by math('$Version') (or any other commands) would not be killed by the command math('quit'), and was just left there in my system managers with the "Memory" colum showing "N/A". Further, if I run the two commands for several times, there would be multiple nonkilled "WolframKernel" processes. Anyone can tell me How I can solve this problem? Thank you very much!
qian shi (view profile)
I come across the same problem with yi huo's. I want to know whether your problem have been solved or not??
Mingxu Zhang (view profile)
Thank "Brenno", "Make sure to include the module "ml64i3.dll" next to the compiled "math.mexw64" file" did slove my problem similar as "Invalid MEXfile 'e:\mathematica_matlab\math.mexw64': The specified module could not be found".
Yu Feng (view profile)
yi huo (view profile)
I wanna use the matlab R2016b link to mathematica 9.0.1, when I run the mathrun.m, it doesn't work and show the messages as the following information: I want help, any answers it ok, ANY LUCK ONE CAN HELP ME?
使用 'MinGW64 Compiler (C)' 编译。
<commandline>:0:0: warning: "__STDC__" redefined
<builtin>: note: this is the location of the previous definition
C:\mathematica_for_matlab\math.c: In function 'MathLinkStringEval':
C:\mathematica_for_matlab\math.c:306:59: warning: passing argument 3 of 'MLGetByteString' from incompatible pointer type [Wincompatiblepointertypes]
MLGetByteString(mlp, (const unsigned char **)&outStr, &len, '\0');
^
In file included from C:\mathematica_for_matlab\math.c:36:0:
C:\mathematica_for_matlab/mathlink.h:4024:16: note: expected 'int *' but argument is of type 'long int *'
MLDECL( int, MLGetByteString, ( MLINK mlp, const unsigned char **sp, int *lenp, long missing));
^
C:\mathematica_for_matlab/mathlink.h:640:58: note: in definition of macro 'MLDECL'
# define MLDECL( rtype, name, params) extern rtype MLAPI name P(params)
^
C:\mathematica_for_matlab\math.c: In function 'WaitForReturnPacket':
C:\mathematica_for_matlab\math.c:540:61: warning: passing argument 3 of 'MLGetByteString' from incompatible pointer type [Wincompatiblepointertypes]
MLGetByteString(mlp, (const unsigned char **)&msgStr, &msglen, '\0');
^
In file included from C:\mathematica_for_matlab\math.c:36:0:
C:\mathematica_for_matlab/mathlink.h:4024:16: note: expected 'int *' but argument is of type 'long int *'
MLDECL( int, MLGetByteString, ( MLINK mlp, const unsigned char **sp, int *lenp, long missing));
^
C:\mathematica_for_matlab/mathlink.h:640:58: note: in definition of macro 'MLDECL'
# define MLDECL( rtype, name, params) extern rtype MLAPI name P(params)
^
<commandline>:0:0: warning: "__STDC__" redefined
<builtin>: note: this is the location of the previous definition
错误使用 mex
C:\mathematica_for_matlab\ml64i3m.lib: error adding symbols: File format not recognized
collect2.exe: error: ld returned 1 exit status
出错 mathrun (line 9)
eval(command)
ctaoist cta (view profile)
I compile the mex file on Mac OS X 10.12 for Mathematica 11.0.1 and MATLAB 2014b by using the command:
mex I/Applications/Mathematica.app/Contents/SystemFiles/Links/MathLink/DeveloperKit/MacOSXx8664/CompilerAdditions L/Applications/Mathematica.app/Contents/SystemFiles/Links/MathLink/DeveloperKit/MacOSXx8664/CompilerAdditions lMLi4 math.c
I have edited the math.c line 227 as suggested in the comments below it.
But I get such error:
Undefined symbols for architecture x86_64:
"_CFDictionaryCreate", referenced from:
_MLAlert_darwin in libMLi4.a(mlosx.c.o)
_MLRequest_darwin in libMLi4.a(mlosx.c.o)
_MLConfirm_darwin in libMLi4.a(mlosx.c.o)
"_CFRelease", referenced from:
_MLAlert_darwin in libMLi4.a(mlosx.c.o)
_MLRequest_darwin in libMLi4.a(mlosx.c.o)
_MLConfirm_darwin in libMLi4.a(mlosx.c.o)
"_CFStringCreateWithCString", referenced from:
_MLAlert_darwin in libMLi4.a(mlosx.c.o)
…………………………………………
"_kCFUserNotificationTextFieldValuesKey", referenced from:
_MLRequest_darwin in libMLi4.a(mlosx.c.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use v to see invocation)
Any advice?
Matt (view profile)
I managed to successfully compile the MEX file using Brenno's instructions. However, when I run the test script I get the following error:
Invalid MEXfile 'C:\XXX\math.mexw64': Invalid access to memory location.
Error in testscript (line 1)
math('quit')
Brenno (view profile)
I have found the solution for the issues that both me and "varan gupta" were having:
Make sure to include the module "ml64i3.dll" next to the compiled "math.mexw64" file, I found the module at:
"C:\Program Files\Wolfram Research\Mathematica\10.4\SystemFiles\Links\MathLink\DeveloperKit\Windowsx8664\SystemAdditions"
I just searched "ml64i3.dll" in the mathematica program directory to find the little sucker.
as long as the "math.mexw64" and "ml64i3.dll" files are in a directory within Matlab's search path you are good to go!
Brenno (view profile)
I am using Windows 7, MatlabR2015b, Mathematica 10.4 and having the same issue as "varan gupta".
Attempted to use Visual Studio Express 2013 without much luck on "mex setup" to recognize it. Finally switched to "Visual Studio 2012 Pro which is free online and got the sucker to compile using the "ml4i3m.lib" as mentioned before.
Any luck anyone?
varan gupta (view profile)
I am using matlab2016a 64 bit.
i am getting error:
Invalid MEXfile 'e:\mathematica_matlab\math.mexw64': The specified module could not be found.
Justine (view profile)
Firstly, thank you this is extremely helpful!
However, it took me 3 days to get this to work, so I thought I'd share what worked for me (Mathematica 10.0, Matlab R2014b, Ubuntu 14.04):
When setting up mex, make sure to change all instances of 'gcc' to 'gcc4.7' and change 'g++' to 'g++4.7' in mexopts.sh
include_path = library_path = /usr/local/Wolfram/Mathematica/10.0/SystemFiles/Links/MathLink/DeveloperKit/Linuxx8664/CompilerAdditions/
The readme file's "libML.a" is "libML64i3.a" for me, so I needed to type:
mex Iinclude_path Llibrary_path lML64i3 math.c
For point 3), I just added the whole folder by adding the following to my startup.m file (not sure how bad that is):
addpath(genpath('/usr/local/Wolfram/Mathematica/10.0/Executables/'));
Even after exporting the LD_LIBRARY_PATH the shared libraries were not being found. After much time spent with nothing helping, doing the following worked:
create a file in /etc/ld.so.conf.d called, say, mathematica.conf containing library_path, i.e. for me the line:
/usr/local/Wolfram/Mathematica10.0/SystemFiles/Links/MathLink/DeveloperKit/Linuxx8664/CompilerAdditions
save the file and then type:
/sbin/ldconfig
If you then type the command:
/sbin/ldconfig p  grep libML64i3.so
its presence should be shown along with the path to it
I hope that saves someone some of the time I lost!
Lars (view profile)
Successfully compiled under Windows7 x8664 with MATLAB R2014b and Mathematica 10.0.0.0 using the default math.c (not the one from 'math_windows.zip') and ml64i3m.lib instead of ml32i1m.lib.
Compiler: Microsoft Visual C++ 2010 (C)
The compiled file 'math.mexw64' seems to work mostly fine on my machine (quick test with the examples from the README  only thing that didn't work was the command 'diag(hilbert)')
ep (view profile)
Does this work with Mathematica 9 and MATLAB R2014a?
karlosgk (view profile)
Fra85 (view profile)
Hi,
I get quite a few compiling errors when producing the mex file. I am using Microsoft Visual C++ 2010 Express and MATLAB Version 7.11.0.584 (R2010b). After adding folders to path, I get:
LINK : warning LNK4044: unrecognized option '/lkernel32'; ignored
Creating library C:\Users\FRANCE~1\AppData\Local\Temp\mex_v3XQyS\templib.x and object C:\Users\FRANCE~1\AppData\Local\Temp\mex_v3XQyS\templib.exp
math.obj : error LNK2019: unresolved external symbol MLClose referenced in function CloseMathLink
math.obj : error LNK2019: unresolved external symbol MLNewPacket referenced in function WaitForReturnPacket
math.obj : error LNK2019: unresolved external symbol MLDisownString referenced in function WaitForReturnPacket
math.obj : error LNK2019: unresolved external symbol MLGetByteString referenced in function WaitForReturnPacket
math.obj : error LNK2019: unresolved external symbol MLNextPacket referenced in function WaitForReturnPacket
math.obj : error LNK2019: unresolved external symbol MLClearError referenced in function HandleMathLinkError
math.obj : error LNK2019: unresolved external symbol MLErrorMessage referenced in function HandleMathLinkError
math.obj : error LNK2019: unresolved external symbol MLEndPacket referenced in function OpenMathLink
math.obj : error LNK2019: unresolved external symbol MLPutString referenced in function OpenMathLink
math.obj : error LNK2019: unresolved external symbol MLPutFunction referenced in function OpenMathLink
math.obj : error LNK2019: unresolved external symbol MLOpen referenced in function OpenMathLink
math.obj : error LNK2019: unresolved external symbol MLPutDoubleArray referenced in function PutArrayToMathematica
math.obj : error LNK2019: unresolved external symbol MLPutSymbol referenced in function PutArrayToMathematica
math.obj : error LNK2019: unresolved external symbol MLDisownDoubleArray referenced in function GetArrayFromMathematica
math.obj : error LNK2019: unresolved external symbol MLGetDoubleArray referenced in function GetArrayFromMathematica
math.obj : error LNK2019: unresolved external symbol MLCheckFunction referenced in function GetArrayFromMathematica
math.obj : error LNK2019: unresolved external symbol MLGetType referenced in function GetArrayFromMathematica
math.mexw64 : fatal error LNK1120: 17 unresolved externals
C:\PROGRA~1\MATLAB\R2010B\BIN\MEX.PL: Error: Link of 'math.mexw64' failed.
Thank you for your help.
Francesco
Jessica (view profile)
I've used this for a few years and find it works very well. I'm trying now to compile it on a Mac running OS 10.7.5
I'm using the command
mex I/usr/include/ lMLi3 math.c
and get
if: Expression Syntax.
ld: library not found for lMLi3
collect2: ld returned 1 exit status
mex: link of ' "math.mexmaci64"' failed.
The library file is definitely in the directory I'm specifying. I see a note in the README that the library path needs to be on the (DY)LD_LIBRARY_PATH  could this be the problem? Any advice would be appreciated
Anh Nguyen (view profile)
I have the same problem when trying to install the packet. I am using Matlab2011b (64bit), Mathematica, 8.0 Windows 7. When I run "mex  setup" from Matlab, it shows
C:\PROGRA~1\MATLAB\2011B\BIN\MEX.PL: Error: '–setup' not found.
Error using mex (line 206)
Unable to complete successfully.
I appreciate very much if anyone can help.
jure (view profile)
i forgot to tell; I have Mathematica 8, MATLAB R2011b and Windows Vista
jure (view profile)
I have troubles with installing this toolbox. After choosing Microsoft Visual C/C++, Mexsetup gives me an error:
mexsetup
Usage:
MEX [option1 ... optionN] sourcefile1 [... sourcefileN]
[objectfile1 ... objectfileN] [libraryfile1 ... libraryfileN]
Use the help option for more information, or consult the MATLAB API Guide.
C:\PROGRA~1\MATLAB\R2011B\BIN\MEX.PL: Error: No file names given.
Undefined function or variable 'setup'.
I have no idea what I'm doing wrong, so if anyone can help me I'll be really grateful. Thanks.
Georg Wechslberger (view profile)
In newer OS X Version you have to add the additional flag
"framework Foundation"
to CLIBS in mexopts.sh
Ross Anderson (view profile)
ahmed abd el aziz (view profile)
how i download toolbox thanks in advance
Huang Meng (view profile)
I wonder how to pass the symbolic in matlab to mathematica and return the result to matlab
Matthias (view profile)
Hello,
I liked this toolbox very much. I used it successfully with Matlab R2010a and Mathematica 7.0. But now it won't start anymore. I get following error:
"MathLink connection unexpectedly NULL!"
I additionally installed Mathematica 8.0. Is this problem or is it because of some windows updates?
Abdulwahab Abokhodair (view profile)
An excellent contribution. Stable and reliable. Thank you Ben.
Denis Rosset (view profile)
Excellent package, thank you !
Tomohiko Takamura (view profile)
This works under x64 environment;
Mathematica 7.0 win64, MATLAB win64 7.10, Visual Studio 2008, Vista x64.
You have to use mldev64\include and lib\ml64i3m.lib instead of 32bits one.
Be careful not to use Visual Studio Express edition.
I failed to compile mex at first, as they have no x64 libs.
Thx.
Dmitry Savransky (view profile)
As usual from this author, a great addition to MATLAB. Quick note for those compiling on OS X  make sure you edit math.c line 227 as suggested in the comments below it, but don't worry about setting the library path. Your mex line should be something like:
mex I/Applications/Mathematica.app/SystemFiles/Links/MathLink/DeveloperKit/CompilerAdditions/ L/Applications/Mathematica.app/SystemFiles/Links/MathLink/DeveloperKit/CompilerAdditions/ lMLi3 math.c
Jonas Morsbøl (view profile)
Tested with MATLAB 2009b and Mathematica 7 on Win Vista. Seems to work fine!
Ahmad Chkeir (view profile)
hello guys.
I just installed Matlab 2009a but it dosen't include symbolic toolbox. I downloaded this file "Mathematica Symbolic Toolbox for MATLABVersion 2.0" but I didn't know what to do later. how can
i add the symbolic tool to my matlab ?
Gonçalo Tavares (view profile)
Hi,
I downloaded this package but got a segmentation violation when running the supplied precompiled math.dll. I am using Matlab 2008a and Mathematica 6.0. Then I copied the mathlink.h and the ml32i1m.lib from the Mathematica directory and tried compiling math.c. However, when I run the mathrun.m script on Matlab I get this error:
C:\PROGRA~1\MATLAB\R2008A\BIN\MEX.PL: Error: 'and' not found.
??? Error using ==> mex at 207
Unable to complete successfully.
Any help?
Thanks a lot.
Gonçalo
Error in ==> mathrun at 8
eval(command)
Martin (view profile)
I try to install it on Mac OS 10.4.
I cannot compile math.c with mex, i get a parse error the following error:
In file included from math.c:35:
/Applications/Mathematica 5.2.app/AddOns/MathLink/DeveloperKit/Darwin/CompilerAdditions/mathlink.h:92: error: parse error before 'yet'
/Applications/Mathematica 5.2.app/AddOns/MathLink/DeveloperKit/Darwin/CompilerAdditions/mathlink.h:408: error: syntax error before 'enum'
math.c: In function 'MathLinkStringEval':
math.c:332: warning: passing argument 3 of 'MLGetByteString' from incompatible pointer type
math.c: In function 'WaitForReturnPacket':
math.c:566: warning: passing argument 3 of 'MLGetByteString' from incompatible pointer type
Can anybody help me?
Thanks
In case anyone gets here b/c they're having the same problem I was, I figured out how to fix the problem.
The issue is that when you do: lML the compiler looks for a library named libML.a. However, on my machine the library is named libMLi3.a.
Therefore if I run:
/Applications/MATLAB74/bin/mex I/Applications/Mathematica.app/SystemFiles/Links/MathLink/DeveloperKit/CompilerAdditions/ L/Applications/Mathematica.app/SystemFiles/Links/MathLink/DeveloperKit/CompilerAdditions/ lMLi3 math.c
Then everything works out hunky dory.
Thanks,
AS
I can't get this to compile on my Mac (OS 10.5.5).
I changed the math.c file as instructed in the readme. When i compile I get an error:
$ /Applications/MATLAB74/bin/mex I/Applications/Mathematica.app/SystemFiles/Links/MathLink/DeveloperKit/CompilerAdditions/ L/Applications/Mathematica.app/SystemFiles/Links/MathLink/DeveloperKit/CompilerAdditions/ lML math.c
ld: library not found for lML
collect2: ld returned 1 exit status
mex: link of 'math.mexmac' failed.

Anyone have any suggestions as to why that is not working?
Thanks,
AS
optical laser
dear ben do you know why i recieved incorrect result by this:
k=sym('k','positive');
z1=1.21+0.008*i
k1=((z1k))^(1/2);
t=2*pi*k/(imag(k1))
s=int(t,k);
Not thoroughly tested, but so far appears to do just what the help files say. This is an invaluable tool to supplement the numeric and applicationspecific capabilities of MATLAB with the symbolic and programming (Map[], Apply[], etc.)strengths of Mathematica. Just what I needed. Fantastic! (Note: MathSource link is not right as of 20060531. should be space between final '624/' and 'to'.)
Wow! Appreciate this a lot.
Awesome! you saved me from coding MathieuC, thank you
Hi,
Thank you for updating the archive to work with matlab 7.0.
Could you please check the .tar archive?The I could not open the archive because it seems to be corrupted.
thanks a lot
Walid