Call MATLAB from Google Colab - matlab

Is it possible to used MATLAB commands from Google Colab (Jupiter on cloud)?
For example, I would like to call Risk Management Toolbox functions like bin(vbt, Name, Value), tbfi(vbt, Name, Value) or tuff(vbt, Name, Value) in Google Colab.
I tried without success
import matlab.engine
eng = matlab.engine.start_matlab()

Nope. Google Colab runs its Python code on Google's server-side Python environment. I don't think Google has bought Matlab for everybody.
Some Matlab code can be run under GNU Octave, a FLOSS clone of Matlab. That can be installed in your Google Colab session's environment by calling !apt install octave in a notebook cell.

Yes.
To activate this option use:
!apt install octave

Related

Issue with CPLEX installation for 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

How to run system commands in Octave for OPM flow reservoir simulator?

I do research in oil simulation, I normally use a simulator called Eclipse from a company called Schlumberger and I was able to use it from my scripts from Matlab using the following command.
% file name 'ICFM.DATA';
system(['eclrun',' eclipse ', C:Path\ICFM.DATA]); % Command to run ECLIPSE
Now I had installed a new Free simulator (OPM.org) in linux and I am using Octave for programming. but I am unable to find out how to run simulator from Octave.
The simulator can be run simply by writing
flow ICFM.DATA
and the results using a command
ecl_summary ICFM.DATA
I want to be able to run and get the results from with in Octave but I have not being able as in Matlab.
Any suggestions? someone?
Assuming both the flow and ecl_summary commands are on your system path (i.e. the "linux" path, not in octave), then it should simply be a matter of:
system('flow /my/path/to/ICFM.DATA');
system('ecl_summary /my/path/to/ICFM.DATA');
(where you should change /my/path/to with whatever path your data file is in).
I found that I am able to run the simulation using the syntaxes
unix('flow ICFM.DATA')
This is in Matlab R2017b for Ubuntu 16.04
Initially I got an error as the output was reporting:
....'GLIBCXX_3.4.21' not found
All the problem was due to a Matlab issue that was solved using the answer on
https://askubuntu.com/questions/719028/version-glibcxx-3-4-21-not-found
which was to type:
LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libstdc++.so.6" matlab
on the terminal.

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

Does Scilab have a Server version available?

Could anyone please tell if Scilab has a Server version so tasks may be executed by running Scilab from 1 central location?
It depends on your usecase.
If you have a high perfomance server that you want to perform the calculations, scilab has a scilab-cli mode which you could start remotely over ssh (as suggested here: https://stackoverflow.com/a/2732991/1149326). See description on --no-gui flag in documentation.
If you want a more interactive session running on a server, (so people don't have to install scilab locally), take a look at the efforts to make a scilab kernel that integrates into jupyter notebooks.
You can see an example Scilab Jupyter notebook here.

Is there a way to install a toolbox from Matlab's command windows?

I am using matlab on a high performance computer (HPC). But they don't have a toolbox I need. I need to install it . Is it possible that I install a toolbox via matlab script locally?
Yes, look at Matlab's addpath, genpath and savepath functions.
Either use addpath(genpath(...)) in the command line followed by savepath to permanently (and globally) add it to the path. Or else you could have addpath(genpath(...)) at the start of your main script to just make sure you always have that toolbox loaded for relevant sessions without permanently adding a toolbox that other users might nit need to the path.
Oh wait, are you asking if you can install a toolbox you don't have at all like from a package repository? In that case I don't think so.