Dynamical system problem

I have this dynamical system:

A = [ -0.313  56.7  0
-0.0139 -0.426 0
0    56.7  0];

B = [0.232
0.0203
0  ];

C = [0 0 1];

D = 0;


I'm using the c2d Matlab command to convert it to discrete time. This system is supposed to be stable but why does it behave like this if I use a sample time lower than 1s? With time sample 1s it is stable and converges to 0.

Also, I'm using full state feedback to place its poles at 0.5

edit

1. Matrices given above are for the continuous time system.
2. The response shown is for the closed loop discrete time system.
3. The full state feedback is designed for the discrete time system.
4. There is one pole at origin only, so unitary multiplicity implies stability.
5. pole placement 0.5+0i for the discrete time system.
6. Full state feedback is designed after doing c2d.
7. To get full state feedback gain I used -place(Ad, Bd, [0.5 0.501 0.502])
8. I also noticed that placing poles in 0.8 in full state feedback the system converges to 0

edit 2

Matlab script:

clear;
close all;
clc;

A = [ -0.313   56.7  0
-0.0139 -0.426  0
0      56.7  0];

B = [0.232
0.0203
0];

C = [0 0 1];

T = 100e-3;

sys = ss(A, B, C, 0);

sysd = c2d(sys, T);

Bd = sysd.B;

Cd = sysd.C;

p_des = [0.5 0.501 0.502];

N = 100;

x(:, 1) = [0 0 pi/9]';

u(:, 1) = 0;

for i=1:N
if (i<N)
x(:, i + 1) = Ad * x(:,i) + Bd * u(:, i);
end
y(:, i) = Cd * x(:, i);

u(:, i + 1) = Kr * x(:, i);
end

k = 1:N;
plot(k, x');


• Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
– Community Bot
Commented Feb 4, 2022 at 13:33
• 1 Matrices given are for the continuous time system. 2 The response shown is for the closed loop discrete time system. 3 The full state feedback is designed for the discrete time system. 4 Why do you say that it's not stable? There is one pole at origin only, so unitary multiplicity implies stability. 5 What do you mean? 6 0.5+0i for the discrete time system. 7 Full state feedback is designed after doing c2d. To get full state feedback gain I used -place(Ad, Bd, [0.5 0.501 0.502]).
– Alex
Commented Feb 4, 2022 at 13:43
• I also noticed that placing poles in 0.8 in full state feedback the system converges to 0
– Alex
Commented Feb 4, 2022 at 14:04
• The negative sign is because of the summing junction with positive inputs. I'm using Matlab not Octave... help place command says "place computes a gain matrix K such that the state feedback u = –Kx places the closed-loop poles at the locations p. In other words, the eigenvalues of A – BK match the entries of p. " In our courses, we studied state feedback considering A+BK in our model, so it explains the negative sign.
– Alex
Commented Feb 4, 2022 at 14:49
• I added the Matlab script
– Alex
Commented Feb 5, 2022 at 13:24

What was supposed to be implemented: $$u_i = Kr\cdot x_i$$. What was actually implemented in the code: $$u_i = Kr\cdot x_{i-1}$$. This effectively made your third order system into a sixth order system (!) which is unstable. See the figure below.

To correct this, the code needs to be slightly modified. Shown below.

%u(:, 1) = 0;

for i=1:N
u(:, i) = Kr * x(:, i);
if (i<N)
x(:, i + 1) = Ad * x(:,i) + Bd * u(:, i);
end
y(:, i) = Cd * x(:, i);
end

• I corrected the code, thank you! If possible I'd ask another question. How can I add an integral action to it? I tried in simulink and it works but how can I do it in command line? I know that I have consider an input like u(:, i) = (yd - y(:, i - 1)) * Ki + Kr * x(:, i) but what is y(:, i - 1) in the first iteration of the loop? Obviously Kr and Ki have to be computed again. Thank you in advance
– Alex
Commented Feb 6, 2022 at 10:15
• What you are describing appears to be derivative action; not integral action. If we know $x(0)$, then we know $y(0)$. If you were asking about $y(-1)$ and if you didn't know it, the default option is to assume zero value. Integral action requires you to add states to the total system to store the integrated value. It is better to ask a separate question (after searching for duplicates) as more people will see it then.
– AJN
Commented Feb 6, 2022 at 12:13
• I asked a separate question, if you could help it would be appreciated. Thank you!
– Alex
Commented Feb 6, 2022 at 13:31