Running the example

The Gurobi MATLAB examples can be found in the <installdir>/examples/matlab/ directory of your Gurobi installation (the default <installdir> for Gurobi 10.0.3 is /opt/gurobi1003/linux64 for Linux). To run one of the examples, first change to this directory in MATLAB, then type its name into the MATLAB prompt. For example, to run example mip1, you would say:

>> cd /opt/gurobi1003/linux64/examples/matlab
>> mip1

If Gurobi was successfully set up for use in MATLAB, you should see the following output in the command window:

          status: 'OPTIMAL'
     versioninfo: [1x1 struct]
         runtime: 3.2401e-04
          objval: 3
               x: [3x1 double]
           slack: [2x1 double]
    poolobjbound: 3
            pool: [1x2 struct]
          mipgap: 0
        objbound: 3
       objboundc: 3
       itercount: 0
    baritercount: 0
       nodecount: 0

x 1
y 0
z 1
Obj: 3.000000e+00

From all this data we only use the fields objval and x in our example. Please refer to the Gurobi Reference Manual for a complete description of all the other output fields.

In order to get more familiar with the Gurobi MATLAB interface, we encourage you to browse through the files in the MATLAB example directory. Often these examples can be used as starting points for your own optimization projects.

Try Gurobi for Free

Choose the evaluation license that fits you best, and start working with our Expert Team for technical guidance and support.

Evaluation License
Get a free, full-featured license of the Gurobi Optimizer to experience the performance, support, benchmarking and tuning services we provide as part of our product offering.
Academic License
Gurobi supports the teaching and use of optimization within academic institutions. We offer free, full-featured copies of Gurobi for use in class, and for research.
Cloud Trial

Request free trial hours, so you can see how quickly and easily a model can be solved on the cloud.

Search