Can you please help me deploy simulink functions for.Net Assembly?

조회 수: 4 (최근 30일)
Rajesh
Rajesh 2023년 9월 28일
답변: Hitesh 2025년 1월 27일
Hi Team
Our aim is to create a Simulink model using a MATLAB script and then convert it to .Net assembly with the aid of the Matlab compiler SDK and Simulink compiler. But We encountered an undeployable error when executing the following functions:
new_system, load_system, open_system, save_system, add_block, add_line, close_system, Simulink. Mdlinfo.
Can you please help us deploy these functions for.Net Assembly?

답변 (1개)

Hitesh
Hitesh 2025년 1월 27일
Hi Rajesh,
Simulink models and certain Simulink functions are not directly supported for deployment through MATLAB Compiler SDK. However, you need to work around this by using MATLAB scripts to perform operations on Simulink models before deployment and then using MATLAB functions that can be compiled.
Kindly follow the following steps to deploy the Simulink functions for .Net Assembly:
  • Script : Write a basic script that creates a Simulink model and performs some operations including functions new_system, open_system, save_system, add_block, add_line, close_system.
% Create a new Simulink model
modelName = 'myModel';
new_system(modelName);
open_system(modelName);
% Add blocks and lines
add_block('built-in/Constant', [modelName, '/Constant']);
add_block('built-in/Scope', [modelName, '/Scope']);
add_line(modelName, 'Constant/1', 'Scope/1');
% Save the model
save_system(modelName);
% Close the system
close_system(modelName);
  • Wrap Model Operations in a MATLAB Function: Create a MATLAB function that can be compiled. This function will not directly manipulate the Simulink model but will instead perform operations that can be compiled.
function result = runSimulinkOperations()
% Call the script that manipulates the Simulink model
mySimulinkScript();
% Return some results or status
result = 'Simulink operations completed successfully';
end
  • Compile the MATLAB Function: Use the MATLAB Compiler to compile the MATLAB function into a .NET assembly.It would generate directive named "output" which will contain all the necessary files.
mcc -W 'dotnet:MySimulinkAssembly,Class1,0.0,private' -T link:lib -d output runSimulinkOperations.m
  • Deploy the .NET Assembly: The compiled .NET assembly can now be used in a .NET environment. Ensure that the MATLAB Runtime is installed on the target machine where the .NET assembly will be used.

카테고리

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

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by