Hi, I have an assignment where I need to design a state-feedback controller in the form: u(k) = K x[k]+ Sy¯[k], with a sampling period pi = 0.05, such that the (discrete-time) closed-loop poles are placed in 0:8 ± 0:1i and the static gain from y¯ to y is 1.
I need to plot a response of the open-loop system to a step of u(t), (which I did)
And 1 plot of the closed-loop response to a step of y¯(t), (doesn't accept S-value, calls it infinite or NaN)
The image below is the initial state-space model:
Here's my code so far:
Phi = [-0.12 0; 5 0]
Gamma = [2.25; 0]
C = [0 1]
D = 0
Pd = ss(Phi, Gamma ,C, D, 0.05)
step(Pd) %plotting the open-loop u(t)
K = [0.45333 -0.00071] %solved K by hand, also had to write down functions so paper is my go to.
PhiCL = Phi+Gamma*[k1 k2]
GammaCL = Gamma *[ s1 ];
syms s1 z;
%MATLAB doesn't compute Z-transform either, tried it by hand, the whole function yields 0
Zg = (C+D*K) * inv(z*eye (2) - PhiCL ) * GammaCL + D*[ s1 ]
Zlim = subs (Zg , z, 1)
s_val = solve (Zlim ==1 , s1) %can't solve fo s1, says: "Empty sym: 0-by-1"
y_bar = ss(PhiCL, GammaCL, (C+D*K), D*s1, 0.05)
%Error using ss (line 284)
%The "B" matrix must be a numeric array with no Inf's or NaN's.
I plotted the y_bar by removing the s1's from D*s1 and GammaCL, and I'm not sure if it converges to 0, I'll attach the plot below. I'm kind of cheating with this plot, and I have to get full points on this assignment or I can't enter the exam.
Thank you in advance!