summaryrefslogtreecommitdiff
path: root/Working_Examples/3432/CH7/EX7.17
diff options
context:
space:
mode:
Diffstat (limited to 'Working_Examples/3432/CH7/EX7.17')
-rwxr-xr-xWorking_Examples/3432/CH7/EX7.17/DEPENDENCIES/acker_dk.sci73
-rwxr-xr-xWorking_Examples/3432/CH7/EX7.17/Ex7_17.sce35
2 files changed, 108 insertions, 0 deletions
diff --git a/Working_Examples/3432/CH7/EX7.17/DEPENDENCIES/acker_dk.sci b/Working_Examples/3432/CH7/EX7.17/DEPENDENCIES/acker_dk.sci
new file mode 100755
index 0000000..3391d24
--- /dev/null
+++ b/Working_Examples/3432/CH7/EX7.17/DEPENDENCIES/acker_dk.sci
@@ -0,0 +1,73 @@
+//------------------------------------------------------------------
+//------------------------------------------------------------------
+//A function written by Deepti Khimani.
+//Usage:-
+//[K, lambda]=acker_dk(a, b, pl)
+//K=acker_dk(a, b, pl)
+//a:- System matrix.
+//b:- input matrix.
+//p:- Desired poles.
+//K:-State feedback gain for the control law u=-Kx.
+//lambda:- Eigen values of (a-b*k)
+//------------------------------------------------------------------
+//------------------------------------------------------------------
+
+function [K, lambda]=acker_dk(a, b, pl)
+ [lhs,rhs]=argn(0)
+
+ if rhs == 0 then
+ disp(["K=acker_dk(a, b, pl)";"[K, lambda]=acker_dk(a, b, pl)"]);
+ disp(["a:- System matrix";"b:- input matrix";"p:- Desired poles"]);
+ disp(["K:-State feedback gain for the control law u=-Kx";...
+ "lambda:- Eigen values of (a-b*k)"]);
+ return;
+ end
+[ra ca]=size(a);
+[rb cb]=size(b);
+l=length(pl);
+
+CO=cont_mat(a,b);
+
+if ra~=l then
+ error(["Dimension error:";"number of desired poles must equal...
+ to order of the system"]);
+elseif ra~=ca then
+ error(["Dimension error:";"system matrix should be...
+ a sqaure matrix"]);
+elseif rb~=ra then
+ error (["Dimension error:","Input matrix should have...
+ as many rows as a system matrix."]);
+elseif rank(CO)<ra then
+ error("system is not controllable");
+end
+//------------------------------------------------------------------
+//controllable canonical form
+[Ac,Bc,T,ind]=canon(a,b);
+
+//CO=zeros(ra,cb);
+for i=1:ra
+ CO(:,ra+1-i)=Ac^(i-1)*Bc;
+end
+//------------------------------------------------------------------
+chr_eq=poly(pl,'s');
+des_chr_coeff=coeff(chr_eq);
+
+des_chr_coeff=des_chr_coeff(1:ra);
+alpha_c=Ac^ra;
+
+for k=1:ra
+ alpha_c=alpha_c + des_chr_coeff(k)*Ac^(k-1)
+end
+//------------------------------------------------------------------
+//State feedback gain
+temp=zeros(1,ra);
+temp(1)=1;
+K=temp*inv(CO)*alpha_c;
+K=K/T;
+lambda=spec(a-b*K);
+endfunction
+//------------------------------------------------------------------
+
+
+
+
diff --git a/Working_Examples/3432/CH7/EX7.17/Ex7_17.sce b/Working_Examples/3432/CH7/EX7.17/Ex7_17.sce
new file mode 100755
index 0000000..3d564e3
--- /dev/null
+++ b/Working_Examples/3432/CH7/EX7.17/Ex7_17.sce
@@ -0,0 +1,35 @@
+//Example 7.17 How zero location affect control law
+// Obtain state feedback gain matrix for the given system
+
+xdel(winsid())//close all graphics Windows
+clear;
+clc;
+//------------------------------------------------------------------
+//(a) state feedback gain matrix for zero at 2.
+//Location of system Zero
+z0=2;
+
+// State space representation
+Ao=[-7 1;-12 0];
+Bo=[1 -z0]';
+Co=[1 0];
+Do=0;
+
+// Desired poles
+Pd=[1 2 4];
+Pc=roots(Pd);
+
+
+// State feedback gain matrix for system zero at -2.0
+K=ppol(Ao,Bo,Pc)
+disp(K,"K=","State feeback gain for a system with zero at 2" )
+//------------------------------------------------------------------
+//Location of system Zero
+z0=-2.99
+B=[1 -z0]';
+// State feedback gain matrix for system zero...
+// at -2.99 (by ackermann's formula)
+exec('./acker_dk.sci', -1);
+K1=acker_dk(Ao,B,Pc)
+disp(K1,"K1","State feeback gain for a system with zero at -2.99")
+//------------------------------------------------------------------