summaryrefslogtreecommitdiff
path: root/modules/cacsd/demos/tracking
diff options
context:
space:
mode:
authorShashank2017-05-29 12:40:26 +0530
committerShashank2017-05-29 12:40:26 +0530
commit0345245e860375a32c9a437c4a9d9cae807134e9 (patch)
treead51ecbfa7bcd3cc5f09834f1bb8c08feaa526a4 /modules/cacsd/demos/tracking
downloadscilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.gz
scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.bz2
scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.zip
CMSCOPE changed
Diffstat (limited to 'modules/cacsd/demos/tracking')
-rwxr-xr-xmodules/cacsd/demos/tracking/track.dem.sce68
1 files changed, 68 insertions, 0 deletions
diff --git a/modules/cacsd/demos/tracking/track.dem.sce b/modules/cacsd/demos/tracking/track.dem.sce
new file mode 100755
index 000000000..5d4535450
--- /dev/null
+++ b/modules/cacsd/demos/tracking/track.dem.sce
@@ -0,0 +1,68 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA
+//
+// This file is released under the 3-clause BSD license. See COPYING-BSD.
+
+mode(1)
+rand("seed", 0)
+rand("normal")
+// Define the plant
+nx=5;ny=1;nu=3;
+Plant=ssrand(ny,nu,nx);
+J=rand(Plant(5));Plant(5)=0*J;
+[F,G,H,J]=Plant(2:5);
+
+// define state space model of the Signal to track
+nw=4;nuu=2;
+A=rand(nw,nw);
+A=A-max(real(spec(A)))*eye(A);
+B=rand(nw,nuu);
+C=2*rand(ny,nw);
+D=0*rand(C*B);
+xx0=0*ones(nw,1);
+Model=syslin("c",A,B,C,D,xx0);
+
+// Input to Model (t is a vector), nuu components
+deff("[ut]=uu(t)","ut=[sin(3*t);cos(0.5*t)]");
+
+// Compute Signal to track
+dt=0.05;tmax=60;
+instants=0:dt:tmax;
+totrack=flts(uu(instants),dscr(Model,dt)); //Signal
+
+my_handle = scf(100001);
+clf(my_handle,"reset");
+plot2d(instants',totrack',axesflag=1);
+
+halt(_("Press Return to continue ... \n"));
+
+clf(my_handle,"reset");
+
+//
+[L,M,T]=gfrancis(Plant,Model);
+
+// Stabilizing the plant
+K=-ppol(F,G,-0.3*ones(1,nx));
+
+// Bigsyst= closed loop system: um --> [yplant;ymodel].
+// full state gain is [K, L - K*T] * (xplant, xmodel) + M * umodel
+BigA=[F+G*K,G*(L-K*T);
+0*ones(nw,nx),A];
+BigC=[H+J*K,J*(L-K*T);
+0*ones(ny,nx),C];
+BigB=[G*M;
+B];
+BigD=[J*M;
+D];
+
+x0=ones(nx,1);
+BigX0=[x0;xx0];
+Bigsyst=dscr(syslin("c",BigA,BigB,BigC,BigD,BigX0),dt);
+
+
+z=flts(uu(instants),Bigsyst);
+plot2d([instants',instants'],..
+[totrack(1,:)',z(1,:)'], axesflag=1);
+curves = gce();
+captions(curves.children,["Signal to track","Computed signal"],"upper_caption");
+xtitle("tracking");