Issue with CPLEX installation for Matlab - matlab

I'm a student currently looking to use the IBM CPLEX solver within MATLAB. I downloaded CPLEX from the IBM website using my student account.
I'm currently having issues with setting up the CPLEX Matlab connector. Matlab currently tells me that CPLEX is not installed or the license server is down when I run commands using CPLEX.
The general online instructions are to add the connecter by using the command in Matlab:
addpath('<CPLEX_Optimization_Studio>/cplex/matlab/')
However, when installed, there wasn't a folder entitled 'matlab' within the cplex folder, and so it can't be added to the MATLAB path.
I'm not sure if there's an issue with the version of CPLEX that I installed, or if this is a common error that can occur during installation.
Please let me know if there's a step I can take to fix this issue!

Matlab connector was removed in CPLEX 20.1
So what you can do:
keep using CPLEX 12.10
call OPL from Matlab :
https://github.com/AlexFleischerParis/howtowithopl/blob/master/callfrommatlab.M
https://github.com/mjbays/MATLAB-OPL-Interface
export MPS from Matlab with https://www.mathworks.com/matlabcentral/fileexchange/19618-mps-format-exporting-tool and then call CPLEX
use a Matlab connector like TOMOPT https://tomopt.com/
Or you can also
use the MATLAB connector from CPLEX 12.10 and export the mps file with
The parameter ExportModel (or exportmodel) takes a file name as an argument.
The default is the empty string (""). For example, opt =
cplexoptimset('exportmodel', 'myModel.lp'); can be used to set the name of
the exported model.
then call CPLEX from Matlab through a command line call

Related

How to use OpenCV in Matlab?

I have looked at many resources. I just want a simple way to use the newest OpenCV with Matlab 2017a. MinGW doesn't work and a compiler but I can't seem to get Visual C++ working. I can use OpenCV in Visual Studio but what compiler does Matlab want from me and how do I obtain it?
There is a way to use opencv from matlab without compiling any mex files, and without using the computer vision toolbox.
You can call opencv through matlab via python commands.
1) Download and install the CPython distribution, not Anaconda
2) from the command prompt, install the opencv and other packages you want using the pip command > python -m pip install opencv-python
3) Follow the procedure in the matlab help for ensuring matlab knows where to look for the python installation
4) use the syntax py.cv2.function to call the opencv function
If you keep the data types as python data types in matlab while using the py.cv2 functions there isn't too much of a speed hit.
As #Miki mentions in the their comment, have you checked out this page on the MathWorks site? It has many resources, the main one is the Computer Vision System Toolbox OpenCV Interface. It comes with some examples which would be a good starting point. And if those aren't close to what you want, try another one of the community examples on the File Exchange and trying to make small changes to it.
For each version of MATLAB you can find the supported compilers in the documentation. You can also use -v flag as shown blow to see all the paths where MATLAB looks for a C++ compiler.
mex -setup -v

Matlab mex wrappers within opencv

I am trying to use Matlab mex wrappers provided by the OpenCV contrib repository https://github.com/opencv/opencv_contrib/tree/master/modules/matlab.
During the OpenCV installation everything goes fine and cmake can find Matlab installation. My OS is ubuntu 16.04 64 bit and I am using Matlab R2015b.
After successful installation, in order to solve conflicts due to internal dynamic libraries, I have put libstdc++ or libgcc_s in the LD_PRELOAD variable before launching matlab. Moreover, based on opencv documentation (opencv_contrib/modules/matlab/) I have added the binding to the matlab path using "addpath('/path/to/opencv/matlab/');"
after running the following code (provided in the opencv documentation):
% load an image (Matlab)
I = imread('cameraman.tif');
% compute the DFT (OpenCV)
If = cv.dft(I, cv.DFT_COMPLEX_OUTPUT);
My code works fine, but whenever I use
I=imread('cameraman.tif');
cv.imshow('test',I)
or
cv.imread('cameraman.tif');
(or I think all modules provided in the opencv highgui module), I face with the following error in matlab:
Invalid MEX-file '/usr/local/opencv-3.1.0/matlab/+cv/imread.mexa64': /usr/lib/libgdal.so.1:
undefined symbol: _ZN11xercesc_3_111InputSource11setEncodingEPKt
I searched a lot to solve the problem, but I couldn't achieve any success. I also tried to build opencv with the flag -D WITH_GDAL=OFF during the opencv cmake installation, but not only it solves the problem, but also makes matlab crash after calling the above-mentioned codes.

How to run a Matlab GUI program without having Matlab installed?

My program performs some simple calculations, look-ups and outputs an answer. What is efficient way to use a Matlab GUI program like I have as a standalone desktop application, which does not require Matlab as a prerequisite?
In order to run any Matlab program on a machine that doesn't have Matlab installed you will need to instal the Matlab Compiler Runtime (MCR).
This is a pre-requisite as it contains the Matlab core functionality that is required by your application and it is royalty-free.
So these are the steps you need:
In your Matlab installation, use the Matlab Compiler to generate a standalone executable of your program.
In the machine you want to deploy your application, Install the same MCR version than the Matlab version you used to generate your program.
Run the program
If you want to run a MATLAB application as stand-alone... whether it be a GUI or a script, it's not required that MATLAB be installed on your computer. You can, in fact, distribute any MATLAB application that you develop to those who don't have MATLAB installed on their computers, but you need the MATLAB Runtime libraries installed before doing so.
On the developer's end, the use of the MATLAB Compiler is required to make your MATLAB application stand-alone. You need to be cautious in that certain MATLAB functions from certain toolboxes cannot be compiled with the MATLAB Compiler if they are used as part of your MATLAB code in order to create your stand-alone application. This link from MathWorks gives a very comprehensive list of what is compatible per toolbox: http://www.mathworks.com/products/compiler/supported/compiler_support.html
On the user's end, simply get them to install the MATLAB Runtime libraries. That can be found here: http://www.mathworks.com/products/compiler/mcr/
Once the developer uses the MATLAB Compiler to create their stand-alone application and once the user installs the MATLAB Runtime libraries, then you can run any stand-alone MATLAB application. Be advised that there is no way around installing the MATLAB Runtime libraries. You need these for any MATLAB application to run stand-alone.

SCIP using Matlab interface

I am trying to use SCIP 3.1.1 along with Matlab in Windows environment
When I run the installscip.m file I get the prompt message that interface Library folder is missing.
/lib/liblpispx.
Can anyone please guide me what step did I skip?
The easiest way to run SCIP in Matlab is by using the OPTI Toolbox. SCIP should be already included, so you don't have to install it yourself.
The current OPTI Toolbox is using SCIP 3.0.1, though.

Unlink MAPLE symbolic from Matlab

When I installed MAPLE I synchronized it with my MATLAB account. My MAPLE license has expired and I am unable to do regular symbolic math in MATLAB. I just tried to define a symbolic character in MATLAB and I got this error:
syms k
??? Error using ==> sym.sym at 198
Error using ==> maplemex
Feature has expired.
Feature: Maple17
Expire date: 09-jan-2015
... and so on. Can someone please help me unlink MAPLE.
If you are using Windows, uninstalling Maple will also remove the Maple toolbox for Matlab. You can also uninstall just the Maple toolbox for Matlab from the Programs and Features menu in the Control Panel.
For Linux, to remove just the toolbox, there is an uninstall script in the root of the Matlab install directory in a folder called Uninstall_MapleToolbox.
One of the possible ways is:
...\toolbox\symbolic\symbolic\#mupad
and from this directory, run the m-file called mupad.m,
and your symbolic math toolbox works fine.
This resolves the problem for once and you would need to run this file everytime when you need the toolbox- mupad.