Filter löschen
Filter löschen

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

38 Ansichten (letzte 30 Tage)
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

Antworten (1)

Ayush Modi
Ayush Modi am 22 Feb. 2024
Bearbeitet: Ayush Modi am 26 Feb. 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!

Kategorien

Mehr zu Get Started with MATLAB Compiler finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by