Effacer les filtres
Effacer les filtres

How can I run a Matlab file with MCR (Matlab Compiler Runtime) in a Linux terminal?

38 vues (au cours des 30 derniers jours)
Nils Schell
Nils Schell le 13 Déc 2019
Modifié(e) : Ayush Modi le 26 Fév 2024
I am trying to create a CI/CD pipeline with GitLab. In this CI/CD pipeline, matlab unit tests should be executed (class-based unit tests).
For this pipeline I use the Matlab Runtime in a Linux docker. The Matlab Runtime is installed in the docker and the projekt files are also in the docker.
My Question:
How can I run a matlab (*.m) file in this Linux docker with a terminal command?
And is it even possible to run matlab files with the MCR?
Thanks for your help

Réponses (1)

Ayush Modi
Ayush Modi le 22 Fév 2024
Modifié(e) : Ayush Modi le 26 Fév 2024
Hi Nils,
Question - 1: How can I run a MATLAB (*.m) file in this Linux docker with a terminal command?
To run MATLAB (*.m) files on a Linux system via a Docker container, you would need a MATLAB installation within the container. However, if you don't have MATLAB installed and only have the MATLAB Compiler Runtime (MCR), you can still run compiled MATLAB applications but not the raw .m files directly.
If you have MATLAB installed in your Docker container, you can run an .m file from the terminal with the following command:
matlab -batch "run('/path/to/your_script.m')" % In Terminal
Question - 2: Is it even possible to run MATLAB files with the MCR?
Yes, it is possible to run MATLAB files with the MCR. Here are the stepwise guide to achieve this:
Step-1: Create a docker file with the following commands:
  • Pull a base MCR image.
  • Set the LD_LIBRARY_PATH environment variable to the MCR installation directories, using the ENV instruction.
  • Copy the compiled MATLAB executable to the image, using the COPY instruction.
  • Run the compiled MATLAB executable, using the CMD instruction.
Step-2: Build the image using the Dockerfile.
  • Navigate to the directory containing your Dockerfile using terminal.
  • Run the below command.
docker build -t <new_image_name_of_choice> .
Step-3: You can then run the docker container with the below command:
docker run -it --rm --shm-size=512M <your_image_name>
Please refer to the following MathWorks documentation for more information on:
Hope this helps!

Catégories

En savoir plus sur Get Started with MATLAB Compiler dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by