no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
Previous revision | |||
— | using_matlab_from_prolog [2014/08/08 09:36] (current) – admin | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Using Matlab from Prolog ====== | ||
+ | \\ | ||
+ | **Note: This page describes experimental code that has not been used in a while. Please try it at your own risk. ** | ||
+ | \\ | ||
+ | |||
+ | The Matlab-Prolog interface [[http:// | ||
+ | |||
+ | You need to set the following values in the Makefile (adapt the pa: | ||
+ | |||
+ | export MATLAB=/ | ||
+ | export MLARCH=glnxa64 | ||
+ | export MLLIBS=-leng -lmx -lmat -licuuc -licudata -licui18n -lz -lreadline | ||
+ | export SO=so | ||
+ | export INCLUDES= | ||
+ | export PLLD=/ | ||
+ | export INSTALL_LIB_TO=~/ | ||
+ | export INSTALL_PL_TO=~/ | ||
+ | export INSTALL_FLAGS=' | ||
+ | |||
+ | Generate a new file and call it: setPathMatlab.m this file should have the following: | ||
+ | |||
+ | p=genpath('/ | ||
+ | addpath(p); | ||
+ | |||
+ | Then move/copy the new file " | ||
+ | |||
+ | Enter the file plml.cpp and add the following (~line 179) | ||
+ | |||
+ | if (ep) { | ||
+ | engEvalString(ep, | ||
+ | this-> | ||
+ | outbuf=new char[BUFSIZE]; | ||
+ | outbuf[BUFSIZE-1]=0; | ||
+ | |||
+ | |||
+ | Configure, make, make install. Set the library path to include the MATLAB directories | ||
+ | export LD_LIBRARY_PATH=/ | ||
+ | |||
+ | Move to the ~/work/owl directory, start Prolog and run the following commands | ||
+ | ?- assert(user: | ||
+ | | ||
+ | true. | ||
+ | | ||
+ | ?- use_module(library(plml)). | ||
+ | % hostname set to atradig131 | ||
+ | % library(hostname) compiled into hostname 0.03 sec, 403,152 bytes | ||
+ | % | ||
+ | % library(utils) compiled into utils 0.01 sec, 65,408 bytes | ||
+ | % 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). | ||
+ | Matlab engine (ml) open. | ||
+ | true. | ||
+ | | ||
+ | ?- float(A)===2*pi. | ||
+ | A = 6.28319. | ||
+ | |||
+ | NOTE: In case you have the following error: | ||
+ | ?- ml_open(ml). | ||
+ | ERROR: Unhandled exception: Unknown message: open engine failed | ||
+ | |||
+ | This means that you need to do the following: | ||
+ | $ sudo apt-get install 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. |