Convert ODE model in MATLAB to Simulink
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello
I have a ODE model in MATLAB but now I want to create a control system for it in SIMULINK. Which is the best way to use it inside simulink? Now I have a .m file that calls (with the solver ode45: [t,y] = ode45(@car,tpo,x0,[]);) to another m file where the ode are defined (car.m). So what I want is to convert the ca.m where 16 differential equations are defined to simulink with the least effort possible. I know that I can rewrite them in simulink with blocks but I want to know if there exists a more direct way to use the m code.
Thank you in advance
0 comentarios
Respuesta aceptada
Seth DeLand
el 13 de Feb. de 2012
Hi Javier,
The easiest way I can think of to convert would be to use a Level 2 MATLAB S-function in Simulink. If you've never used S-functions before, this is a good place to get started: http://www.mathworks.com/help/toolbox/simulink/sfg/f6-12629.html
You can use the same code that you used in car.m for calculating the derivatives in your S-function (this will be in the Derivative function in the S-function). The msfcn_limintm.m S-function gives an example of how this can be done.
Because the outputs of the ODE solver are just the states, the Output function of you S-function should just grab the values of the states and set those as the outputs. This is also done in the msfcn_limintm.m example.
Más respuestas (0)
Ver también
Categorías
Más información sobre Simulink Functions en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!