Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear
- clc
- %% Input:
- numg = 5; % Define numerator of G(s)
- deng = poly([0.4 0.8 5]); % Define denominator of G(s)
- Ts = 600; % Time settling
- Os = 5; % Overshoot (%)
- %% Process
- syms s k1 k2 k3 ke;
- G = tf(numg,deng) % Generate transfer function G(s)
- [Ac Bc Cc Dc] = tf2ss(numg,deng);
- P = flip(eye(order(G)));
- A = inv(P)*Ac*P
- B = inv(P)*Bc
- C = Cc*P
- D = Dc
- Cm = det(ctrb(A,B)) % Controlbility
- zeta = (-log(Os/100))/(sqrt(pi^2+log(Os/100)^2));
- Wn = 4/(zeta*Ts); % pi/(Tp*sqrt(1-zeta^2))
- %% state-feedback control
- pole1 = s^2 + 2*zeta*Wn*s + Wn^2;
- pole2 = s+50
- Anew = A-(B*[k1 k2 k3])
- Ds = expand(pole1*pole2)
- Ts = det(s*eye(3)-Anew)
- % Solve
- Dsm = coeffs(Ds,s);
- Tsm = coeffs(Ts,s);
- k = vpa(struct2cell((solve(Dsm==Tsm))))
- %% Plot
- % Subs k into transfer function
- Ts = subs(Ts,k1,k(1));
- Ts = subs(Ts,k2,k(2));
- Ts = subs(Ts,k3,k(3));
- % Form transfer function
- dent = double(flip(coeffs(Ts,s)));
- Tsc = tf(numg,dent)
- % Plot
- step(Tsc);
- title('State Feedback Controller');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement