Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there debug and release configurations in Matlab

I am coding on both C++ and Matlab. For C++ projects I use VS2013 (or 2015). In VS there are two different default configurations - debug and release and the second one is typically significantly faster. In Matlab I always run my code from Matlab's command line. Is there a way to improve the performance in Matlab by changing the configuration?

I know, that I can compile Matlab code, but will it improve the performance (I typically do either Image analysis or nonlinear system solving)? I also know, that one can make C code from Matlab's code, which sometimes accelerates it.

I didn't find a complete answer on SO. My guess is, that if there are no breakpoints inside my script, it automatically runs in release mode, otherwise in debug mode. I noticed, that if I have a breakpoint at the end of my script, it runs slower.

like image 690
Mikhail Genkin Avatar asked Jan 31 '26 11:01

Mikhail Genkin


1 Answers

In short, the answer is no. Matlab itself has no concept of these configurations.

It comes down to the fact that the C++ code is compiled based on the configuration options before resulting binary is run. Matlab code, on the other hand, contains no compilation step and is simply run by the interpreter. The C++ release configuration typically has compile and linker optimisations enabled, which the debug configuration does not.

The "compilation" of your Matlab code can only occur when you utilise Matlab toolboxes or utilities to convert your Matlab code into C code. I believe there used to be some limitations on which internal Matlab functions could be used in your Matlab code if you are going to convert it to C. If you are able to do so, Matlab will use some build configuration to produce the C code. It's best to check, but I suspect the generated Matlab code is unlikely to be faster, since some of the heavy lifting internal Matlab functions are already coded in C++.

like image 95
BobbyJ Avatar answered Feb 03 '26 05:02

BobbyJ



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!