Path: news.mathworks.com!newsfeed-00.mathworks.com!panix!bloom-beacon.mit.edu!llnews!53ab2750!not-for-mail
From: Peter Boettcher <boettcher@ll.mit.edu>
Newsgroups: comp.soft-sys.matlab
Subject: Re: convert C++ code to M-code
References: <fvqp8o$9s4$1@fred.mathworks.com>
Message-ID: <muyiqxqgt9v.fsf@G99-Boettcher.llan.ll.mit.edu>
Organization: MIT Lincoln Laboratory
User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/23.0.0 (gnu/linux)
Cancel-Lock: sha1:8T+BL4QVl7R2xfh2dDdKWwC8pXE=
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Lines: 32
Date: Wed, 07 May 2008 09:04:12 -0400
NNTP-Posting-Host: 155.34.163.114
X-Complaints-To: news@ll.mit.edu
X-Trace: llnews 1210164811 155.34.163.114 (Wed, 07 May 2008 08:53:31 EDT)
NNTP-Posting-Date: Wed, 07 May 2008 08:53:31 EDT
Xref: news.mathworks.com comp.soft-sys.matlab:467156



"carlos " <pumaju@yahoo.com> writes:

> hi,
>
> i want to convert a C++/C code to Matlab code (M-file) and 
> viceversa, what instructions do i need??
>
> Do you know some simple example that illustrate this?? or 
> some tutorial in the internet or something about this 
> topic?? something specific and short if possible

2 options:

1- Use each set of code in it's native format.  From C code, you can
link in the MATLAB engine API and call MATLAB code directly from C.
From MATLAB, you can compile your C/C++ code and call it directly from
MATLAB.  Both require intermediate knowledge of C programming.  See the
"External Interfaces" section of the MATLAB documentation.

2- Port the code to the other language.  There are no simple rules for
this.  You simply read and understand the algorithm in one language, and
write the code that does the same thing in the other.  Depending on how
complex the code is, when porting from MATLAB to C you might benefit
from the use of a third-party library to help with matrix operations,
such as BLAS/LAPACK, Intel Processing Primitives, or the GNU Scientific
Library.  (Google each of these).  Or, from C to MATLAB, you can often
simplify things tremendously as MATLAB offers many more standard
functions than the C library.

Good luck,

-Peter