discrete and continuous system

8 views (last 30 days)
Michael Schwegel
Michael Schwegel on 16 Feb 2017
Answered: Michael Schwegel on 2 Mar 2017
I want to simulate a dynamical system (using an ordinary differential equation) and a discrete recursive least squares algorithm. A sequential implementation is of no use, since i want the RLS values influencing the input of the system (adaptive control).
Using only matlab how is this situation best implemented? Since ode45 has an adaptive step-length I cannot be sure, if the discrete sampling points are exactly sampled by the solver. Is there any way how I can get by this? In simulink I know this it is possible to define cont. and disc. blocks, but how is this implemented? Without knowing what is happening I don't want to use this. Also I have my full framework built upon matlab only, so I'd rather not use simulink at all.
Things I've thought of:
Zero-Crossings/Events: as far as I can tell I cannot trigger a function, when a zero crossing occurs, right? I could only terminate the integration and start again afterwards.
Which is equivalent to integrate between time steps using odeXY, sample a step, integrate again,..
Thanks for any comments

Answers (1)

Michael Schwegel
Michael Schwegel on 2 Mar 2017
The only deterministic solution I found was to implement my own RK45 with adaptive stepsize. It is designed to take discrete and continuous systems (ode and difference equations) and solves with adaptive stepsize until a new sample has to be taken. This method works like a charm - with slow dynamics only the discrete points are sampled for sufficiently small sampling times and fast dynamics yield small integration stepsizes, as expected!

Products

Community Treasure Hunt

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

Start Hunting!