필터 지우기
필터 지우기

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

조회 수: 38 (최근 30일)
Nils Schell
Nils Schell 2019년 12월 13일
편집: Ayush Modi 2024년 2월 26일
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

답변 (1개)

Ayush Modi
Ayush Modi 2024년 2월 22일
편집: Ayush Modi 2024년 2월 26일
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!

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB Compiler에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by