I often used to apply Euler Method to simulate an ODE, because it's a very simple method. Together with Euler Method I use a for loop.
The for loop might look like this:
x = x0 % initial state vector
M = 1000 % Max step
For k = 1:M
x = Ax + Bu(:, k)
y(:, k) = Cx + Du(:, k)
End
This result a basic simulation of a linear ODE. But if I apply delay in this for loop, how should I do that?
I know that the input need to remember the past inputs. That's the point with the delay. If I do a step simulation of this simulation. I can just use:
u(:, k - L)
Insted of:
u(:, k)
The L is a integer of delayed step and
$$ u(:, k - L) = 0 \forall k - L <= 0 $$
But now, the input u is going do be changed over every step because I am going to do a feedback simulation.
I have the answer here:
I need to have the input as:
Then implementera that in:
Now I got a delay.
For state feedback it is:
Where F is the LQR controller gain matrix.