Differences
This shows you the differences between two versions of the page.
Next revisionBoth sides next revision | |||
using_matlab_from_prolog [2013/02/04 12:13] – created tenorth | using_matlab_from_prolog [2013/02/04 14:12] – tenorth | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | *Use the MATLAB-Prolog interface | + | ====== Using Matlab |
- | * set the following values in the MAKEFILE | + | |
- | | + | The Matlab-Prolog interface [[http://www.swi-prolog.org/contrib/SamerAbdallah/index.html|PLML]] allows to call Matlab functions from Prolog. The following steps describe the setup as it worked in our lab. You will need to adapt the paths to your setup and possibly change other values if you have a different configuration. |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | *generate a new file and call it: setPathMatlab.m this file should have the following: | + | You need to set the following |
- | p=genpath(' | + | export MATLAB=/ |
- | addpath(p); | + | export MLARCH=glnxa64 |
+ | export MLLIBS=-leng -lmx -lmat -licuuc -licudata -licui18n -lz -lreadline | ||
+ | export SO=so | ||
+ | export INCLUDES= | ||
+ | export PLLD=/usr/local/lehrstuhl/DIR/pl/lib/pl/ | ||
+ | | ||
+ | export INSTALL_PL_TO=~/ | ||
+ | export INSTALL_FLAGS=' | ||
- | * move/copy the new file "setPathMatlab.m" to the following | + | Generate a new file and call it: setPathMatlab.m |
- | *Enter the file plml.cpp and add the following (~line 179) | + | p=genpath('/ |
+ | addpath(p); | ||
+ | |||
+ | Then move/copy the new file " | ||
+ | |||
+ | Enter the file plml.cpp and add the following (~line 179) | ||
if (ep) { | if (ep) { | ||
Line 28: | Line 31: | ||
- | * configure, make, make install | + | Configure, make, make install. Set the library path to include the MATLAB directories |
+ | export LD_LIBRARY_PATH=/ | ||
- | * set the library path to include the MATLAB directories | + | Move to the ~/work/owl directory, start Prolog and run the following commands |
- | | + | ?- assert(user: |
- | + | assert(user: | |
- | * move to the ~/work/owl directory | + | true. |
- | + | ||
- | * start Prolog and run the following commands | + | ?- use_module(library(plml)). |
- | ?- assert(user: | + | % hostname set to atradig131 |
- | | + | % library(hostname) compiled into hostname 0.03 sec, 403,152 bytes |
- | + | % | |
- | ?- use_module(library(plml)). | + | % library(utils) compiled into utils 0.01 sec, 65,408 bytes |
- | % hostname set to atradig131 | + | % library(flists) compiled into flists 0.00 sec, 10,456 bytes |
- | | + | % library(plml) compiled into plml 0.08 sec, 619,872 bytes |
- | | + | true. |
- | | + | |
- | | + | ?- ml_open(ml). |
- | % library(plml) compiled into plml 0.08 sec, 619,872 bytes | + | Matlab engine (ml) open. |
- | | + | true. |
- | + | ||
- | ?- ml_open(ml). | + | ?- float(A)===2*pi. |
- | | + | A = 6.28319. |
- | | + | |
- | + | ||
- | ?- float(A)===2*pi. | + | |
- | A = 6.28319. | + | |
- | * NOTE: Just in case you have the following error: | + | NOTE: In case you have the following error: |
?- ml_open(ml). | ?- ml_open(ml). | ||
ERROR: Unhandled exception: Unknown message: open engine failed | ERROR: Unhandled exception: Unknown message: open engine failed | ||
- | * This means that you need to do the following: | + | This means that you need to do the following: |
$ sudo apt-get install csh. | $ sudo apt-get install csh. | ||
- | By default c-shell is installed in /bin/csh. | + | By default c-shell is installed in /bin/csh. That is necessary because you need to have C shell installed in your system as /bin/csh for the matlab engine program to function correctly. You can use any shell, but just that C shell has to be there in the system so that the engine program can use it. |
- | That is necessary because you need to have C shell installed | + | |
- | in your system as /bin/csh for the matlab engine program | + | |
- | to function correctly. You can use any shell, but just that | + | |
- | C shell has to be there in the system so that the engine | + | |
- | program can use it. | + |