Is it possible to create a Docker image from Simulink model?

19 ビュー (過去 30 日間)
MathWorks Support Team
MathWorks Support Team 2023 年 5 月 4 日
編集済み: MathWorks Support Team 2023 年 5 月 8 日
Is it possible to create a Docker image from Simulink model? Could you provide an example if possible?

採用された回答

MathWorks Support Team
MathWorks Support Team 2023 年 5 月 8 日
編集済み: MathWorks Support Team 2023 年 5 月 8 日
You can deploy a MATLAB function that simulates a Simulink model to Docker using MATLAB Compiler and Simulink Compiler. You will need MATLAB that is R2020b or newer. We suggest you use newer releases that are more stable and have more functionality.
Since Simulink Compiler generates platform-specific binaries and the fact that Docker containers are Linux based, you need to build and package on Linux.
Please refer to the following example steps.
1. Start with the following function.
function deployedScript()
in = Simulink.SimulationInput('sldemo_suspn_3dof');
in = in.setVariable('Mb', 1000);
in = simulink.compiler.configureForDeployment(in);
out = sim(in);
plot(out.ScopeData.signals.values)
pause(3)
close(gcf)
end
2. ​Build the example into a standalone application.
>> r = compiler.build.standaloneApplication('deployedScript.m')
3. Package that executable into a Docker container. It may take a while.
>> compiler.package.docker(r)
4. Run the newly created container.
>> !docker run --rm -e "DISPLAY=:1.0" -v /tmp/.X11-unix:/tmp/.X11-unix deployedscript

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeContainers についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by