summaryrefslogtreecommitdiff
path: root/3432/CH7/EX7.18/Ex7_18.sce
diff options
context:
space:
mode:
authorprashantsinalkar2017-10-10 12:27:19 +0530
committerprashantsinalkar2017-10-10 12:27:19 +0530
commit7f60ea012dd2524dae921a2a35adbf7ef21f2bb6 (patch)
treedbb9e3ddb5fc829e7c5c7e6be99b2c4ba356132c /3432/CH7/EX7.18/Ex7_18.sce
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/CH7/EX7.18/Ex7_18.sce')
-rw-r--r--3432/CH7/EX7.18/Ex7_18.sce56
1 files changed, 56 insertions, 0 deletions
diff --git a/3432/CH7/EX7.18/Ex7_18.sce b/3432/CH7/EX7.18/Ex7_18.sce
new file mode 100644
index 000000000..5be65a2a6
--- /dev/null
+++ b/3432/CH7/EX7.18/Ex7_18.sce
@@ -0,0 +1,56 @@
+//Example 7.18
+//Introducing the reference input.
+
+xdel(winsid())//close all graphics Windows
+clear;
+clc;
+//------------------------------------------------------------------
+//Pendulum state model;
+w0=1;
+
+F=[0 1;-w0^2 0];
+G=[0 1]';
+H=[1 0]; //representing x1 and x2 states as outputs
+J=0;
+n=sqrt(length(F));
+
+//computing state feedback matrix to place poles at [-2 -2]
+exec('./acker_dk.sci', -1);
+K=acker_dk(F,G,[-2, -2]);
+//------------------------------------------------------------------
+//augmented matrix for tracking the reference
+A=[F G;H J];
+N=A\[zeros(1,n) 1]';
+Nx=N(1:n);
+Nu=N(n+1);
+
+//feedforward gain (input weight)
+Ntilde=Nu+K*Nx;
+
+//------------------------------------
+//Alternately, it can be computed as /
+Ntilde1=-inv(H*inv(F-G*K)*G); // /
+//------------------------------------
+
+//Closed loop system and step response
+syscl=syslin('c',(F-G*K),G*Ntilde,H,J); //closed loop system
+
+t=0:0.1:7;
+[y x]=csim('step',t,syscl); //closed loop response
+plot(t',x');
+
+u=-K*x+Ntilde;
+plot(t',u'/4,'r--'); //control law u plot (scaled to 1/4 in figure);
+legend("x1","x2","u/4");
+xset('font size',3);
+xstring(5,0.93,"$x_{ss}$")
+xstring(5,0.25,"$u_{ss}$")
+
+//Title, labels and grid to the figure
+exec .\fig_settings.sci; //custom script for setting figure properties
+title('Step response of undamped oscillator to reference input',...
+'fontsize',3);
+xlabel('Time t (sec.)','fontsize',2);
+ylabel('Amplitude','fontsize',2);
+
+//------------------------------------------------------------------