4 Installation

In this section we discuss how to install and setup the MOSEK Optimization Toolbox for MATLAB.


Before running this MOSEK interface please make sure that you:

  • Installed MOSEK correctly. Some operating systems require extra steps. See the Installation guide for instructions and common troubleshooting tips.
  • Set up a license. See the Licensing guide for instructions.


The Optimization Toolbox for MATLAB can be used with MATLAB version r2014a or newer.

Locating Files

The files in Optimization Toolbox for MATLAB are organized as reported in Table 4.1.

Table 4.1 Relevant files for the Optimization Toolbox for MATLAB.
Relative Path Description Label
<MSKHOME>/mosek/8/toolbox/r2014a Toolbox <TOOLBOXDIR>
<MSKHOME>/mosek/8/toolbox/r2014aom Toolbox (without overloading) <TOOLBOXOMDIR>
<MSKHOME>/mosek/8/toolbox/examples Examples <EXDIR>
<MSKHOME>/mosek/8/toolbox/data Additional data <MISCDIR>

where <MSKHOME> is the folder in which the MOSEK package has been installed.

Setting up the paths

To use Optimization Toolbox for MATLAB the path to the toolbox directory must be added via the addpath command in MATLAB. Use the command

addpath <MSKHOME>/mosek/8/toolbox/r2014a

or, if you do not want to overload functions such as linprog and quadprog from the MATLAB Optimization Toolbox with their MOSEK versions, then write

addpath <MSKHOME>/mosek/8/toolbox/r2014aom

On the Windows platform the relevant paths are

addpath <MSKHOME>\mosek\8\toolbox\r2014a
addpath <MSKHOME>\mosek\8\toolbox\r2014aom

Alternatively, the path to Optimization Toolbox for MATLAB may be set from the command line or it can be added to MATLAB permanently using the configuration file startup.m or from the FileSet Path menu item. We refer to MATLAB documentation for details.

4.1 Testing the installation

You can verify that Optimization Toolbox for MATLAB works by executing


in MATLAB. This should produce a message similar to this:

Matlab version: (R2014a)
Architecture  : GLNXA64
Warning: The mosek optimizer could not be invoked from the command line. Most likely the path has not been configured correctly. The mosek optimizer can still be invoked from the MATLAB environment.
> In mosekdiag at 23
mosekopt: /home/andrea/mosek/8/toolbox/r2014a/mosekopt.mexa64

MOSEK Version (Build date: 2016-8-16 00:52:47)
Copyright (c) MOSEK ApS, Denmark. WWW: mosek.com
Platform: Linux/64-X86

Found MOSEK version : major(8), minor(0), build(0), revision(34)
mosekopt is working correctly.
Warning: MOSEK Fusion is not configured correctly; check that mosek.jar is added to the javaclasspath.


If you only want to use Optimization Toolbox for MATLAB then the warnings about command line and Fusion interface can be ignored.

4.1.1 Troubleshooting

Undefined Function or Variable mosekopt

If you get the MATLAB error message

Undefined function or variable 'mosekopt'

you have not added the path to the Optimization Toolbox for MATLAB correctly as described above.

Invalid MEX-file

For certain versions of Windows and MATLAB, the path to MEX files cannot contain spaces. Therefore, if you have installed MOSEK in C:\Program Files\Mosek and get a MATLAB error similar to:

Invalid MEX-file <MSKHOME>\Mosek\8\toolbox\r2014a\mosekopt.mexw64

try installing MOSEK in a different directory, for example C:\Users\<someuser>\ .

Output Arguments not assigned

If you encounter an error like

Error in ==> mosekpt at 1
function [r,res] = mosekopt(cmd,prob,param,callback)

Output argument "r" (and maybe others) not assigned during call to

then a mismatch between 32 and 64 bit versions of MOSEK and MATLAB is likely. From MATLAB type

which mosekopt

which (for a succesful installation) should point to a MEX file,


and not to a MATLAB .m file,