Package Matlab program into .exe stand-alone executable program

1. Find and install the runtime

Enter mcinstaller directly in the command window . If the following content appears, it means that there is no runtime plug-in:

Enter the command compiler.runtime.download and wait for a moment to download:

The download may fail due to network reasons. You can directly download the zip file according to the URL given in the prompt. After the download is complete, set the path of the MATLAB complier compiler in matlab:

Enter mcinstaller again , if the following content appears, it means that there is a runtime plug-in in Matlab:

2. Package Matlab program as .exe file

Let's take this simple program as an example to demonstrate how to package a Matlab program into an .exe file:

% close all
read = xlsread('1.xlsx');
xlswrite('2.xlsx',read+1);

This program reads the 1.xlsx file, and saves the data in it as 2.xlsx file after +1.

Find Application Compiler in APP:

Configure the following:

Click Package to start packaging:

After the packaging is complete, a folder and a .prj file will appear, open the folder:

for_redistribution: files used to install applications and MATLAB Runtime, before running the packaged executable file, install the runtime environment under this folder; for_redistribution_files_only: packaged stand-alone executable
file;
for_testing: files created by MCC, like Binary files and jar, header and source files, use these files to test the packaging effect;
PackagingLog.html: The log file generated by the compiler.

3. Run the .exe file on a computer without Matlab installed

将文件夹放到未安装Matlab的电脑上。

  • 运行for_redistribution中的MyAppInstaller_mcr.exe文件,安装Matlab Runtime;

  • 运行for_redistribution_files_only中的.exe文件,可以发现程序运行成功后生成了2.xlsx

Guess you like

Origin blog.csdn.net/Cretheego/article/details/128899008