<p>A researcher has created a small simulation in MATLAB and we want to make it accessible to others. My plan is to take the simulation, clean up a few things and turn it into a set of functions. Then I plan to compile it into a C library and use <a href="https://en.wikipedia.org/wiki/SWIG" rel="nofollow noreferrer">SWIG</a> to create a Python wrapper. At that point, I should be able to call the simulation from a small Django application. At least I hope so.</p>
<p>Do I have the right plan? Are there are any serious pitfalls that I'm not aware of at the moment?</p>

[{'answer_id': 5302, 'author': 'Michal Sznajder', 'author_id': 501, 'author_profile': 'https://Stackoverflow.com/users/501', 'pm_score': 3, 'selected': True, 'text': '<p>I remember that I was able to wrap a MATLAB simulation into a <a href="https://en.wikipedia.org/wiki/Dynamic-link_library" rel="nofollow noreferrer">DLL file</a> and then call it from a <a href="https://en.wikipedia.org/wiki/Embarcadero_Delphi" rel="nofollow noreferrer">Delphi</a> application. It worked really well.</p>\n'}, {'answer_id': 16189, 'author': 'Bartosz Radaczyński', 'author_id': 985, 'author_profile': 'https://Stackoverflow.com/users/985', 'pm_score': 1, 'selected': False, 'text': '<p>Perhaps try <a href="http://python.net/crew/theller/ctypes/" rel="nofollow noreferrer">ctypes </a>instead of SWIG. If it has been included as a part of Python 2.5, then it must be good :-)</p>\n'}, {'answer_id': 138534, 'author': 'Eli Bendersky', 'author_id': 8206, 'author_profile': 'https://Stackoverflow.com/users/8206', 'pm_score': 2, 'selected': False, 'text': '<p>I\'d also try <a href="https://en.wikipedia.org/wiki/Ctypes" rel="nofollow noreferrer">ctypes</a> first.</p>\n<ol>\n<li>Use the MATLAB compiler to compile the code into C.</li>\n<li>Compile the C code into a DLL.</li>\n<li>Use ctypes to load and call code from this DLL</li>\n</ol>\n<p>The hardest step is probably 1, but if you already know MATLAB and have used the MATLAB compiler, you should not have serious problems with it.</p>\n'}, {'answer_id': 1659332, 'author': 'Dima', 'author_id': 13313, 'author_profile': 'https://Stackoverflow.com/users/13313', 'pm_score': 3, 'selected': False, 'text': '<p>One thing to remember is that the MATLAB compiler does not actually compile the MATLAB code into native machine instructions.  It simply wraps it into a stand-alone executable or a library with its own runtime engine that runs it.  You would be able to run your code without MATLAB installed, and you would be able to interface it with other languages, but it will still be interpreted MATLAB code, so there would be no speedup.</p>\n'}]
['https://Stackoverflow.com/questions/5136', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/676/']