1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
---|
2 | <html xmlns="http://www.w3.org/1999/xhtml"> |
---|
3 | <head> |
---|
4 | <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> |
---|
5 | <title>mixpp: How to write and use mex files for Matlab</title> |
---|
6 | <link href="tabs.css" rel="stylesheet" type="text/css"/> |
---|
7 | <link href="doxygen.css" rel="stylesheet" type="text/css"/> |
---|
8 | </head> |
---|
9 | <body> |
---|
10 | <!-- Generated by Doxygen 1.6.1 --> |
---|
11 | <script type="text/javascript"> |
---|
12 | <!-- |
---|
13 | function changeDisplayState (e){ |
---|
14 | var num=this.id.replace(/[^[0-9]/g,''); |
---|
15 | var button=this.firstChild; |
---|
16 | var sectionDiv=document.getElementById('dynsection'+num); |
---|
17 | if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){ |
---|
18 | sectionDiv.style.display='block'; |
---|
19 | button.src='open.gif'; |
---|
20 | }else{ |
---|
21 | sectionDiv.style.display='none'; |
---|
22 | button.src='closed.gif'; |
---|
23 | } |
---|
24 | } |
---|
25 | function initDynSections(){ |
---|
26 | var divs=document.getElementsByTagName('div'); |
---|
27 | var sectionCounter=1; |
---|
28 | for(var i=0;i<divs.length-1;i++){ |
---|
29 | if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){ |
---|
30 | var header=divs[i]; |
---|
31 | var section=divs[i+1]; |
---|
32 | var button=header.firstChild; |
---|
33 | if (button!='IMG'){ |
---|
34 | divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild); |
---|
35 | button=document.createElement('img'); |
---|
36 | divs[i].insertBefore(button,divs[i].firstChild); |
---|
37 | } |
---|
38 | header.style.cursor='pointer'; |
---|
39 | header.onclick=changeDisplayState; |
---|
40 | header.id='dynheader'+sectionCounter; |
---|
41 | button.src='closed.gif'; |
---|
42 | section.id='dynsection'+sectionCounter; |
---|
43 | section.style.display='none'; |
---|
44 | section.style.marginLeft='14px'; |
---|
45 | sectionCounter++; |
---|
46 | } |
---|
47 | } |
---|
48 | } |
---|
49 | window.onload = initDynSections; |
---|
50 | --> |
---|
51 | </script> |
---|
52 | <div class="navigation" id="top"> |
---|
53 | <div class="tabs"> |
---|
54 | <ul> |
---|
55 | <li><a href="main.html"><span>Main Page</span></a></li> |
---|
56 | <li class="current"><a href="pages.html"><span>Related Pages</span></a></li> |
---|
57 | <li><a href="annotated.html"><span>Classes</span></a></li> |
---|
58 | <li><a href="files.html"><span>Files</span></a></li> |
---|
59 | </ul> |
---|
60 | </div> |
---|
61 | <div class="navpath"><a class="el" href="manual.html">User Manual</a> |
---|
62 | </div> |
---|
63 | </div> |
---|
64 | <div class="contents"> |
---|
65 | |
---|
66 | |
---|
67 | <h1><a class="anchor" id="mexfiles">How to write and use mex files for Matlab </a></h1><h2><a class="anchor" id="use"> |
---|
68 | Howto use predefined mexfiles</a></h2> |
---|
69 | <p>A range of mexfiles is predefined in directory <code>library/mex</code>. Many of these mexfile process ui files (see <a class="el" href="ui_page.html">User Infos and their use</a>) examples of these files are in directory <code>library/tutorial</code>. Note that in order to run these files you need to let matlab know where to find them: </p> |
---|
70 | <div class="fragment"><pre class="fragment">>> addpath path_to_bdm/library/mex |
---|
71 | </pre></div><p>Then, you can go to <code>library/tutorial</code> and run e.g. <code>arx_test_mex</code>.</p> |
---|
72 | <h2><a class="anchor" id="write"> |
---|
73 | Howto write custom mex file</a></h2> |
---|
74 | <p>Due to special nature of the mex files, the mex file can be split in three parts: </p> |
---|
75 | <ul> |
---|
76 | <li>input conversion, where input arguments are converted to IT++ structures, </li> |
---|
77 | <li>main body of algorithm, where any C++ bdm constructions can be used, </li> |
---|
78 | <li>output conversion, where resulting IT++ structures are converted to mxArrays.</li> |
---|
79 | </ul> |
---|
80 | <p>The first and the third part is achieved using prepared IT++ routines, see IT++ documentation.</p> |
---|
81 | <p>Script <code></code>./buildmex is prepared to compile and link the mexfile with bdm. </p> |
---|
82 | <div class="fragment"><pre class="fragment">$ ./buildmex.sh my_mex_file.cpp |
---|
83 | </pre></div><p> on Linux, or </p> |
---|
84 | <div class="fragment"><pre class="fragment">$ ./buildmex.bat my_mex_file.cpp |
---|
85 | </pre></div><p> on Windows.</p> |
---|
86 | <p>Example of a mexfile: </p> |
---|
87 | <div class="fragment"><pre class="fragment"></pre></div> </div> |
---|
88 | <hr size="1"/><address style="text-align: right;"><small>Generated on Sun Aug 30 22:10:50 2009 for mixpp by |
---|
89 | <a href="http://www.doxygen.org/index.html"> |
---|
90 | <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> |
---|
91 | </body> |
---|
92 | </html> |
---|