Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MATLAB Compiler vs MATLAB Coder

What's the difference between the two?

As far as I understand it, MATLAB Compiler wraps the MATLAB code into a .exe file so that it can be used without installing MATLAB, and only requires the MCR. On top of it MATLAB Builder NE can also be used to produce .Net assemblies to be used with .Net framework instead of the .exe file, but they still require MCR.

Now I don't understand what MATLAB Coder used for? It generates C/C++ code. But is the MATLAB code really converted into C/C++, or is it merely packaged like in the case of MATLAB Compiler? Does it also need the MCR to run?

I understand that this is not exactly a programming question. But I have searched the internet and still haven't found a clear answer. These are very expensive products so I would like to know what I am getting into.

like image 447
Win Coder Avatar asked Aug 08 '13 12:08

Win Coder


People also ask

What is MATLAB Coder and compiler?

MATLAB Compiler SDK extends MATLAB Compiler by the ability to provide shared libraries (. dll, . so), so that your MATLAB programs can be packaged into software components for integration with other programming languages. MATLAB Coder on the other hand, provides readable and portable C source code.

What is MATLAB Coder?

MATLAB Coder™ generates C and C++ code from MATLAB® code for a variety of hardware platforms, from desktop systems to embedded hardware. It supports most of the MATLAB language and a wide range of toolboxes. You can integrate the generated code into your projects as source code, static libraries, or dynamic libraries.

What is MATLAB Compiler?

MATLAB Compiler™ enables you to share MATLAB® programs as standalone applications, web apps, and Docker container images. With MATLAB Compiler, you can also package and deploy MATLAB programs as MapReduce and Spark™ big data applications or as Microsoft® Excel® Add-ins.

Do I need MATLAB Compiler?

Compilers are not required to run basic MATLAB or Simulink, or the basic functions of most of the toolboxes. Fortran is not generated by anything in MATLAB, so you only need a Fortran compiler if you intend to link to Fortran code or you intend to write mex routines in Fortran.


1 Answers

MATLAB Compiler encrypts and archives your MATLAB code (which remains as MATLAB .m code), and packages it in a thin executable (either .exe or .dll) wrapper. This is delivered to the end user along with the MATLAB Compiler Runtime (MCR). If you wish, the MCR can be packaged within the executable as well.

The MCR is freely redistributable, and you can think of it as essentially a copy of MATLAB without a front-end desktop.

When the user runs the executable, it dearchives and decrypts the MATLAB code, and runs it against the MCR instead of MATLAB. Applications delivered via this method should therefore run exactly the same as they do within MATLAB (including the same speed).

MATLAB Coder converts a subset of the MATLAB language into C code. This can then be used in many different ways, including being brought back into MATLAB as a mex file, compiled with a C compiler to be called from another application, or delivered to an embedded device. Since it is C code rather than MATLAB code, it will often (though not always) run much faster than the original MATLAB code. The C code does not require the MCR. The supported subset of the MATLAB language is very extensive, but there are a few notable restrictions that you would want to look into before committing to this workflow. The code produced is C code, although it can produce a C++ wrapper if you have a need to use a C++ compiler rather than a C compiler.

MATLAB Compiler is intended for the use case that you want to simply and (fairly) straightforwardly share a MATLAB application that you've written with someone who does not have a copy of MATLAB. Since the deployed .m code is encrypted, it can also be used to share MATLAB code while protecting intellectual property.

MATLAB Coder has other use cases, such as wanting to speed up MATLAB code by converting to a mex file, or needing to produce C code for another application or an embedded device.

If you have more detailed questions, I would really recommend that you just call up MathWorks and ask them.


Edit: The information above is correct for versions of MATLAB R2014b and below. As of MATLAB R2015a, functionality from MATLAB Compiler has been remixed with functionality from the MATLAB Builder products, and there is also a new product MATLAB Compiler SDK.

As of R2015a, MATLAB Compiler works in the same way as described above (i.e. encrypt, archive and package, but not producing C), but will now package as .exe, and as an Excel add-in (.xla). Prior to R2015a, this functionality used to be present in the product MATLAB Builder EX for Excel.

As of R2015a, MATLAB Compiler no longer produces .dll components. This functionality has been moved to the new product MATLAB Compiler SDK, which also includes functionality to produce .NET assemblies and Java classes. Prior to R2015a, this functionality used to be present in the products MATLAB Builder NE for .NET and MATLAB Builder JA for Java.

In other words:

In R2014b and below, we had:

MATLAB Compiler: produce .exe and .dll components

MATLAB Builder NE for .NET: produce .NET assemblies

MATLAB Builder JA for Java: produce Java classes

MATLAB Builder EX for Microsoft Excel: produce Excel add-ins.

In R2015a, we have:

MATLAB Compiler: produce .exe and Excel add-ins

MATLAB Compiler SDK: produce .dll, .NET assemblies and Java classes.

The scope and use-cases of MATLAB Coder have not changed across these releases (although there are new features).


Edit: As of R2015b, MATLAB Compiler SDK also produces Python packages.


Additional information on distinguishing MATLAB Coder and MATLAB Compiler for C/C++ can be found here.

Comparison table of different MATLAB Products for code generation.

like image 106
Sam Roberts Avatar answered Sep 24 '22 02:09

Sam Roberts