MATLAB Fast Automation: Tired of Working? Here's Your Step-by-Step Action Plan to Automate Your Work With MATLAB.

 

       

In this article, you will learn:

  • How to run a Simulink model from MATLAB
  • How to set up the simulation time of your model from MATLAB

Run a Simulink Model With the sim Command

Let us say we have the following model: 

You can run a Simulink model from MATLAB using the sim command:

% name of your model
modelName = 'mySimpleModel';
 
% sim will simulate the model in argument
sim(modelName);

Set up the Desired Simulation Time from Matlab

If you want to set up the duration time of your simulation from MATLAB, you can add a variable in your simulink model: 

Then, you can define this variable in your workspace or m file and run the simulation again as the following:

% time defines in seconds
t = 5;
modelName = 'mySimpleModel';
sim(modelName);

Leave a Reply