How to convert a .m file to an .exe

236 vues (au cours des 30 derniers jours)
Ivan Mich
Ivan Mich le 2 Mai 2020
Hello,
I would like to ask something. How could I convert a matlab code (.m file) to an executable file (I mean to an .exe file)?
Could anyone help me?

Réponse acceptée

Ivan Mich
Ivan Mich le 6 Mai 2020
Actually, I have tried these code and it works:
clc
clear
mcc -m file.m

Plus de réponses (1)

Walter Roberson
Walter Roberson le 2 Mai 2020
You would use either MATLAB Compiler or MATLAB Coder.
MATLAB Compiler can compile most MATLAB (but not all!) to .exe. The resulting .exe does not require a MATLAB license to run. The .exe will be very close to the same speed as MATLAB itself... including taking a notable time to start up.
MATLAB Coder can transform some MATLAB to C or C++ code, that can then be compiled. The generated code does not require a MATLAB license to run. The generated code will be be optimized by your compiler, and in a fair number of cases will be faster than MATLAB itself. However, if your code made heavy use of vectorized mathematics, then there are cases where MATLAB itself would be faster, because the MATLAB Coder generated code might not call on the highly optimized libraries that MATLAB has access to. It is typical to need to make little adjustments to a notable portion of the MATLAB code to get it to work with MATLAB Coder. MATLAB Coder cannot compile graphics.
MATLAB Compiler is roughly the third-most expensive MATLAB product. MATLAB Coder is notably more expensive than MATLAB Compiler, and might be the most expensive product MATLAB offers. (I am not positive about that though, as I have not seen a quotation on the Automated Driving toolbox, which I understand is quite expensive.)
MATLAB Compiler is not available to Student licenses (or to Home licenses.) MATLAB Coder is available to Student licenses (but not to Home licenses.)

Catégories

En savoir plus sur C Shared Library Integration dans Help Center et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by