Project

General

Profile

Morph-M Matlab - How to use Morph-M with Matlab » History » Version 21

Serge Koudoro, 12/29/2008 03:11 PM

1 1 Serge Koudoro
h1. How to use Morph-M with Matlab 
2
3 5 Serge Koudoro
h2{color:#8B0000}. Introduction
4 1 Serge Koudoro
5 10 Serge Koudoro
The Matlab capabilities can be extended through domain specific software packages called Matlab toolboxes. A typical Matlab toolbox is a directory structure which contains new data structures and function definitions that extend Matlab's capabilities to a new science or engineering area. A Matlab toolbox user simply copies the toolbox directory structure and tells Matlab where the toolbox is located. The toolbox defined functions and datatypes then become available from Matlab. Java is very extensively supported in Matlab. Since we have Java wrappers in Morph-M, we can quickly get access to all of Morph-M in Matlab using the Java wrappers.
6 1 Serge Koudoro
7 10 Serge Koudoro
8 1 Serge Koudoro
h2{color:#8B0000}. Setting up Java-Wrapped Morph-M in Matlab
9 4 Serge Koudoro
10 18 Serge Koudoro
*%{color:#006400}+Current Version:+%*
11
12
* Matlab 7.04(R14)
13
* Java 1.6
14
* Morph-M 2.6
15
16
Before starting, make sure that Java Virtual Machine of Matlab is the same as Java-Wrapped Morph-M. If not, go to the @settings and Compabilities problems@ section.  
17
18 13 Serge Koudoro
*%{color:#006400}+Step 1 :+%*
19 11 Serge Koudoro
20 13 Serge Koudoro
We need to tell Matlab where to find the Java class files for Morph-M and the Matlab load library work-around. This can be done @dynamically@ from the Matlab command prompt, *but these commands will need to be applied each time Matlab is started*:
21 11 Serge Koudoro
<pre>
22
javaaddpath('insert-your-path-to-the-Morph-M-build-directory-here/bin/Morpheejava.jar')
23
javaaddpath('insert-your-path-to-the-directory-containing-LoadLibrary.class-here');
24 1 Serge Koudoro
</pre>
25
26 13 Serge Koudoro
There are two alternatives *for a permanent addition to the Matlab* Java class path. 
27 14 Serge Koudoro
28
* The first method requires root or administrative access to the Matlab installation on your system (if Matlab is installed in your local Unix directory you can also use this method). This change will apply to all users who access this Matlab installation. as root (Unix) or as an account with administrator priveledges (Windows), execute the following from within Matlab, or directly edit the *classpath.txt* file with any text editor: @edit([matlabroot '/toolbox/local/classpath.txt']);@
29
30 1 Serge Koudoro
* The second method is to modify a local copy of the *classpath.txt* file in the local users Matlab startup directory. Make a copy of $matlabroot/toolbox/local/classpath.txt into your Matlab startup directory and edit that copy (on Unix the Matlab startup directory is in your home directory under .matlab/R2008a).
31 14 Serge Koudoro
32
* *For the both methods*, Add the following lines to your *classpath.txt* (system or local copy):
33
34 1 Serge Koudoro
<pre>
35 10 Serge Koudoro
insert-your-path-to-Morph-M-build-directory/Morpheejava.jar
36 1 Serge Koudoro
insert-your-path-to-the-directory-containing-LoadLibrary.class-here
37 12 Serge Koudoro
</pre>
38 1 Serge Koudoro
39 13 Serge Koudoro
*%{color:#006400}+Step 2 :+%*
40
41 14 Serge Koudoro
Next, we need to tell Matlab where to *find the dynamic libraries* for Morph-M by editing *librarypath.txt*. Again, there are two options:
42 11 Serge Koudoro
* *Option one* requires root or administrator priveledges and changes the Matlab search path for all users of the Matlab installation. As root (Unix) or as an account with administrator priveledges (Windows), directly edit the librarypath.txt file with any text editor: @edit([matlabroot '/toolbox/local/librarypath.txt']);@ . Then, Add the following line to librarypath.txt : path-to-the-Morph-M-build-directory (e.g: $matlabroot/morphm/dll)
43 1 Serge Koudoro
44 11 Serge Koudoro
* *Options two* modifies a local copy of *librarypath.txt* file and applies to the local user. Make a copy of $matlabroot/toolbox/local/librarypath.txt your Matlab startup directory and edit that copy (on Unix the Matlab startup directory is in your home directory under .matlab/R2008a). Add the following line to librarypath.txt : path-to-the-Morph-M-build-directory (e.g: /usr/local/lib/morphm or d:/morphm/bin)
45 1 Serge Koudoro
46 6 Serge Koudoro
h2{color:#8B0000}. Using Java-Wrapped Morph-M within Matlab
47 1 Serge Koudoro
48 6 Serge Koudoro
In order to use Morph-M stuff in Matlab, first execute
49 8 Serge Koudoro
<pre>LoadLibrary.loadLibrary('Morpheejava');</pre>
50 16 Serge Koudoro
51
!Matlab_Intro.png!
52 15 Serge Koudoro
53 17 Serge Koudoro
54
All functions available are loaded, Now we are ready to go. You can see a lot of examples [[Morph-M within Matlab Examples|Here]].  
55 1 Serge Koudoro
56 5 Serge Koudoro
57 8 Serge Koudoro
h2{color:#8B0000}. Settings and Compabilities problems
58 18 Serge Koudoro
59 20 Serge Koudoro
*%{color:#006400}+Which JVM version is in Matlab ??+%*
60 18 Serge Koudoro
61
To know that, just execute this following linne in Matlad command Prompt:
62
<pre> version -java </pre>
63
64 20 Serge Koudoro
*%{color:#006400}+Matlab JVM version is not the same as Morph-M. How can I change it ??+%*
65 18 Serge Koudoro
66
if you would like to use a different version of JVM than the default used in MATLAB, Matlab support provide an easy method "here":http://www.mathworks.com/support/solutions/data/1-1812J.html?solution=1-1812J
67
+Note:+
68
69
* JVM 1.3.1 for MATLAB 6.5.1 (R13SP1)
70
* JVM 1.4.2 for MATLAB 7.0.1 (R14SP1)
71
* MATLAB 7.0.4 (R14SP2) and later versions use JVM 1.5. There are components that may not work properly under a different version of the JVM.
72
* MATLAB 7.4 (R2007a) and later versions use JVM 1.6
73 5 Serge Koudoro
74 21 Serge Koudoro
*%{color:#006400}+The Java "loadlibrary" command not work+%*
75
76
This is a Matlab bug. you can find a work-around "here":http://www.mathworks.com/support/solutions/data/1-1A2HO.html?solution=1-1A2HO
77
78 8 Serge Koudoro
h2{color:#8B0000}. Matlab Morph-M Toolbox Release