Using Matlab with C++
Using Matlab with C++
(OP)
Hi there.
I'm working on a project in C++. The thing is that all the math part of it I'm doing in Matlab, that I find so much easier on those aspects.
I'm not quite sure how can I incorporate the Matlab code into the C++ program, though. I readed about creating a dll library, but it was really vague information. Can you guide me through the main steps?
Thanks
I'm working on a project in C++. The thing is that all the math part of it I'm doing in Matlab, that I find so much easier on those aspects.
I'm not quite sure how can I incorporate the Matlab code into the C++ program, though. I readed about creating a dll library, but it was really vague information. Can you guide me through the main steps?
Thanks





RE: Using Matlab with C++
TTFN
FAQ731-376: Eng-Tips.com Forum Policies
RE: Using Matlab with C++
Fe
RE: Using Matlab with C++
TTFN
FAQ731-376: Eng-Tips.com Forum Policies
RE: Using Matlab with C++
h
Don't get confused by the term "Matlab Compiler", this is a deployment tool.
Matlab does ship with LCC, but be aware that this is a C compiler and will not build C++ programs.
- Steve
RE: Using Matlab with C++
Thanks!
RE: Using Matlab with C++
Apparently I have to use the command MCC, and in its help it says :
MCC MATLAB to C/C++ Compiler (Version 4.0).
MCC [-options] fun [fun2 ...]
OPTIONS:
B <filename>[:<arg>[,<arg>]] Specify bundle file. <filename> is a text file
containing Compiler command line options. The Compiler behaves as if the
"-B <filename>" were replaced by the contents of the bundle file. Newlines
appearing in these files are allowed and are treated as whitespace.
The MathWorks provides options files for the following:
cpplib Used for building a C++ library
The thing is that it doesn't work that way, or maybe I'm missing something.
Attached is the matlab code I want to convert to C++.
Thanks
RE: Using Matlab with C++
You need to write your own C++ code that does FFT. Do it in discrete form. I'd give you the one I wrote for this, but then I'd have to "sue" you.
It's best if you learn this by doing it, so to speak.
Fe
RE: Using Matlab with C++
a) Convert the Matlab code into equivalent C++ and incorporate that C++ into your program.
b) Retain your Matlab code, but somehow call it from your C++ program.
c) Other.
===
a) The "Matlab compiler" will not help you here. You will almost certainly need to either rewrite the math code in C++. There are some free Matrix class libraries out there. Or you could write your own. I wrote my own when I needed to convert someone elses Matlab into C++. It's educational.
b) As I said, the Matlab Engine is designed for this. It will consume a Matlab license when it runs though of course.
c) ??
- Steve
RE: Using Matlab with C++
Thanks people!