clear all

A = [0 1; -5 -6];
B = [0; 1];

dt = 0.001;
sim_time = 0:dt:6;

i = 1;
for t = sim_time
  if mod(t, 1) > 0.5 
    u = 0;
  else
    u = 1;
  end
  if t == 0
    x = [0; 0]; % x0
  else
    dx = A*x + B*u;
    x = x + dx*dt;
  end
  x_1(i) = x(1);
  x_2(i) = x(2);
  i = i + 1;
end

clf
plot(sim_time, x_1)
hold
plot(sim_time, x_2)
grid on
legend("x_1", "x_2")
xlabel("time [s]"); ylabel("state vector")
title("time response")
print("fig_euler_octave.png", "-dpng")
