Matlab to C++ Converter??
이전 댓글 표시
Hi, may I know is there any build in converter inside Matlab R2010b? TQ...
답변 (3개)
Walter Roberson
2012년 2월 24일
0 개 추천
You can get the optional (costly) MATLAB Coder product.
There are a fair number of restrictions as to what can be converted. For example, no graphics.
Superb
2012년 2월 24일
0 개 추천
댓글 수: 10
Walter Roberson
2012년 2월 24일
Good question. MATLAB Coder was released for R2011a .
There were other products before that, but I am not certain that this kind of generation was available for MATLAB itself (as opposed to Simulink.)
Note: the list price for MATLAB Coder is $US6,500; if you are going to spend that much it would seem to make sense to pay any differential support costs needed to bring your MATLAB to a current version.
But please don't spend that kind of money without having studied the details of what MATLAB Coder can and cannot compile. It is primarily for numeric algorithms at the moment, with little support for data structures or toolboxes.
Superb
2012년 2월 24일
Sean de Wolski
2012년 2월 24일
Does your university have a license?
Walter Roberson
2012년 2월 24일
MATLAB Coder and all related products are *not* available for the Student Version.
They _are_ available in the Academic version, but there are license restrictions about who can compile and distribute what and to whom. I have outlined my _interpretation_ in some past messages, but it would be far better to talk to your university's account representative.
Superb
2012년 2월 25일
Walter Roberson
2012년 2월 25일
I do not know if it is on the standard distribution media or not these days. If it is, it would have to be specifically selected for installation.
Superb
2012년 2월 25일
Walter Roberson
2012년 2월 25일
You need to have a (supported) C or C++ compiler installed, and you need to run
mex -setup
to tell MATLAB which compiler to use.
Superb
2012년 2월 26일
Walter Roberson
2012년 2월 26일
You upgraded to R2011a ? If so then Yes, VS 2010 C++ can be used.
If you are using MATLAB in 64 bit mode then there is additional work involved; see http://www.mathworks.com/support/compilers/R2011a/win64.html
Superb
2012년 2월 26일
0 개 추천
댓글 수: 7
Jiro Doke
2012년 2월 26일
So did you run
mex -setup
and selected Visual Studio 2010? Then try running your coder project again.
Superb
2012년 2월 26일
Jiro Doke
2012년 2월 26일
With MATLAB Coder, you can generate both C/C++ code as well as MEX. In general, MEX is just a wrapper around the C code and compiled to run in MATLAB. In the coder project, you can specify the output type to be MEX, C/C++ library, or C/C++ executable. In all cases, you can see the C source code.
I can't really tell you _why_ "try" is not supported. It just is not.
http://www.mathworks.com/help/toolbox/eml/ug/bq37dee.html
Superb
2012년 2월 27일
Walter Roberson
2012년 2월 27일
There is no C equivalent to "try" (at least not that is of any practical use to anyone if you are not writing your own processor kernel code.)
C++ has exceptions, but the mechanisms do not correspond at well to MATLAB's exceptions.
Superb
2012년 2월 28일
Walter Roberson
2012년 2월 28일
I have gathered the impression that the code generated is in the common subset of C and C++, except that C++ style declarations might be used for external functions, extern "C" { .... } . There might be some other differences, perhaps; no one has happened to mention them in the messages I've read (the price of the toolkit is sufficiently high that there is no chance my workplace will buy it in the near future.)
If you did manage to find a way to generate C++ code, it still would not handle try/catch . C++'s exceptions are not the same thing.
My mention about writing processor kernel code has to do with the fact that the exception processing that _is_ possible in C, is of such limited flexibility, that nearly the only use for it (other than saying "I quit") is in embedded processing systems with paged memory, to detect a segmentation violation, swap in the appropriate page, and continue on. Not at all the kind of thing you are looking for.
It seems plausible to me that if you are using library routines that might produce meaningful exceptions for try/catch use, then _probably_ your code is not in the subset that can be compiled.
Verify your inputs before you send them to the lower levels so that you do not need to rely on try/catch.
카테고리
도움말 센터 및 File Exchange에서 Call C++ from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!