Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: convert C++ code to M-code

Subject: convert C++ code to M-code

From: carlos

Date: 06 May, 2008 23:23:04

Message: 1 of 3

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

thanks for your help

Subject: Re: convert C++ code to M-code

From: Peter Boettcher

Date: 07 May, 2008 13:04:12

Message: 2 of 3

"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

Subject: Re: convert C++ code to M-code

From: Steve Amphlett

Date: 07 May, 2008 13:17:03

Message: 3 of 3

"carlos " <pumaju@yahoo.com> wrote in message <fvqp8o$9s4
$1@fred.mathworks.com>...
> 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
>
> thanks for your help

There is no language called C++/C. If your code is C,
conversion to M should be straightforward and will cut down
your line count considerably. If your code is C++, you may
find that converting your classes and/or templates will be
tricky.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
c compiler mfile carlos 06 May, 2008 19:25:08
rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics