summaryrefslogtreecommitdiff
path: root/3432/DEPENDENCIES
diff options
context:
space:
mode:
authorprashantsinalkar2017-10-10 12:27:19 +0530
committerprashantsinalkar2017-10-10 12:27:19 +0530
commit7f60ea012dd2524dae921a2a35adbf7ef21f2bb6 (patch)
treedbb9e3ddb5fc829e7c5c7e6be99b2c4ba356132c /3432/DEPENDENCIES
parentb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (diff)
downloadScilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.tar.gz
Scilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.tar.bz2
Scilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.zip
initial commit / add all books
Diffstat (limited to '3432/DEPENDENCIES')
-rw-r--r--3432/DEPENDENCIES/acker_dk.sci73
-rw-r--r--3432/DEPENDENCIES/fig_settings.sci9
-rw-r--r--3432/DEPENDENCIES/zpk_dk.sci43
3 files changed, 125 insertions, 0 deletions
diff --git a/3432/DEPENDENCIES/acker_dk.sci b/3432/DEPENDENCIES/acker_dk.sci
new file mode 100644
index 000000000..3391d2454
--- /dev/null
+++ b/3432/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/3432/DEPENDENCIES/fig_settings.sci b/3432/DEPENDENCIES/fig_settings.sci
new file mode 100644
index 000000000..5d5e7d435
--- /dev/null
+++ b/3432/DEPENDENCIES/fig_settings.sci
@@ -0,0 +1,9 @@
+//------------------------------------------------------------------
+//figure handel settings
+f=get("current_figure"); //Current figure handle
+f.background=8; //make the figure window background white
+l=f.children(1);
+l.background=8 ;//make the text background white
+id=color('grey');
+xgrid(id);
+//------------------------------------------------------------------
diff --git a/3432/DEPENDENCIES/zpk_dk.sci b/3432/DEPENDENCIES/zpk_dk.sci
new file mode 100644
index 000000000..95b4e6c13
--- /dev/null
+++ b/3432/DEPENDENCIES/zpk_dk.sci
@@ -0,0 +1,43 @@
+//------------------------------------------------------------------
+//------------------------------------------------------------------
+//A function written by Deepti Khimani.
+//Usage:-
+//p=zpk_dk(sl)
+//[p, z]=zpk_dk(sl)
+//[p, z, k]=zpk_dk(sl)
+//p:- Poles of the system
+//z:- zeros of the system
+//k:- DC gain of the system
+//------------------------------------------------------------------
+//------------------------------------------------------------------
+
+function[pl,zr,k]=zpk_dk(sysmodel)
+ [lhs,rhs]=argn(0)
+
+ if rhs == 0 then
+ disp(["p=zpk_dk(sl)";"[p, z]=zpk_dk(sl)";"[p, z, k]=zpk_dk(sl)"]);
+ disp(["p:- Poles of the system";"z:- zeros of the system"]);
+ disp("k:- DC gain of the system");
+ return;
+ end
+
+ if typeof(sysmodel)=="rational" then
+ sys=tf2ss(sysmodel);
+ pl=spec(sys.A);
+ zr=trzeros(sys);
+ temp1=poly(zr,'s','roots')/poly(pl,'s','roots');
+ temp2=sysmodel/temp1;
+ temp3=tf2ss(temp2);
+ k=temp3.D;
+ elseif typeof(sysmodel)=="state-space" then
+ pl=spec(sysmodel.A);
+ zr=trzeros(sysmodel);
+ g=ss2tf(sysmodel);
+ temp1=poly(zr,'s','roots')/poly(pl,'s','roots');
+ temp2=g/temp1;
+ temp3=tf2ss(temp2);
+ k=temp3.D
+ else
+ error("Wrong type of input argument.")
+ end
+endfunction