How do I simulate simulink model using the ode45.m function at the command prompt or in an m file?

55 views (last 30 days)
I need to run simulink model using the matlab function ode45.m, and I don't know how to do this as even with a simple first order system in simulink 1/(s+1) with sine input to it of Amplitude=1, and frequency set to 1 and it is saved as firstOrderSys.mdl . When I call this in an ode45 function: >>[t,x]=ode45(@firstOrderSys,[0 10],[0 0]) I get the following error message: >>Simulink model firstOrderSys was called with incorrect number of arguments
Many thanks!
Regards, Osman

Answers (1)

Mischa Kim
Mischa Kim on 13 May 2014
Osman, how about doing it all in Simulink?
If you select Simulation > Model Configuration Parameters in the Simulink model window you can select ode45 as the solver.
  1 Comment
Osman Ahmed
Osman Ahmed on 13 May 2014
Hi Mischa, Thank you very much for the response. I am aware of this, but I want to be able to do it at the Matlab code level using the ode45 function. Any suggestions on how that could be done? Cam the ode45 take a mdl model as an input argument or it is not possible?
Thanks,

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!