Is it possible to use the simulink model as a function in matlab?

Antworten (2)

Andreas Goser
Andreas Goser am 11 Jul. 2024

0 Stimmen

You can run a Simulink simulation in MATLAB using the sim command, do you mean this?
Hi Marina,
Yes, it is possible to call a Simulink model from within a MATLAB function. Here’s a step-by-step guide on how to do this:
  • The "load_system" function loads the Simulink model into memory.
% Load the Simulink model
modelName = 'my_model';
load_system(modelName);
  • The "sim" function runs the simulation. The output of the simulation is captured in the simOut variable.
% Run the simulation
simOut = sim(modelName);
  • Close the Model: The "close_system" function closes the model without saving any changes.
% Close the model without saving changes
close_system(modelName, 0);
Please refer the below documentations for load_system, sim and close_system:
I hope it helps!

Kategorien

Gefragt:

am 11 Jul. 2024

Kommentiert:

am 14 Aug. 2024

Community Treasure Hunt

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

Start Hunting!

Translated by