Mercurial > hg > octave-avbm
changeset 3386:a5288b88446f
[project @ 1999-12-15 22:56:00 by jwe]
author | jwe |
---|---|
date | Wed, 15 Dec 1999 22:56:03 +0000 |
parents | 10f21f7ccc7f |
children | eb4223985ca8 |
files | scripts/ChangeLog scripts/control/analdemo.m scripts/control/bddemo.m scripts/control/dgkfdemo.m scripts/control/frdemo.m scripts/control/moddemo.m scripts/control/sysrepdemo.m |
diffstat | 7 files changed, 136 insertions(+), 128 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,5 +1,13 @@ 1999-12-15 John W. Eaton <jwe@bevo.che.wisc.edu> + * control/bddemo.m: Make it more likely to work with + whitespace_in_literal_matrix = "ignore". + * control/analdemo.m: Ditto. + * control/dgkfdemo.m: Ditto. + * control/frdemo.m: Ditto. + * control/sysrepdemo.m: Ditto. + * control/moddemo.m: Ditto. + * control/dezero.m: Use toascii to convert string to ASCII value instead of multiplying it by 1.
--- a/scripts/control/analdemo.m +++ b/scripts/control/analdemo.m @@ -47,9 +47,9 @@ clc disp("System Grammians: (see Moore, IEEE T-AC, 1981) \n"); disp("Example #1, consider the discrete time state space system:\n"); - a=[1 5 -8.4;1.2 -3 5;1 7 9] - b=[1 5;2 6;-4.4 5] - c=[1 -1.5 2;6 -9.8 1] + a=[1, 5, -8.4; 1.2, -3, 5; 1, 7, 9] + b=[1, 5; 2, 6; -4.4, 5] + c=[1 -1.5, 2; 6, -9.8, 1] d=0 prompt disp("\nThe discrete controllability grammian is computed as follows:"); @@ -69,9 +69,9 @@ clc disp("Example #2, consider the continuous state space system:\n"); - a=[1 3 -10.2;3.7 -2 9;1 3 7] - b=[1 12;6 2;-3.8 7] - c=[1 -1.1 7;3 -9.8 2] + a=[1, 3, -10.2; 3.7, -2, 9; n1, 3, 7] + b=[1, 12; 6, 2; -3.8, 7] + c=[1, -1.1, 7; 3, -9.8, 2] d=0 prompt disp("\nThe continuous controllability grammian is computed as follows:"); @@ -94,9 +94,9 @@ disp("System zeros (tzero) example\n"); disp("Example #1, consider the state space system:\n"); - a=[0 1 0;-10 -2 0;-10 0 -8] - b=[0;1;9] - c=[-10 0 -4] + a=[0, 1, 0; -10, -2, 0; -10, 0, -8] + b=[0; 1; 9] + c=[-10, 0, -4] d=1 prompt disp("\nTo compute the zeros of this system, enter the following command:\n"); @@ -135,7 +135,7 @@ clc disp("Continuous => Discrete and Discrete => Continuous conversions (c2d,d2c)"); disp("\nExample #1, consider the following continuous state space system"); - cmd = "sys_cont = ss2sys([-11 6;-15 8], [1;2], [2 -1], 0);"; + cmd = "sys_cont = ss2sys([-11, 6; -15, 8], [1; 2], [2, -1], 0);"; eval(cmd); disp(cmd); disp("Examine the poles and zeros of the continuous system:"); @@ -170,9 +170,9 @@ disp("Algebraic Riccati Equation (are, dare)"); disp("\nExample #1, consider the continuous state space system:\n"); - a=[1 3 -10.2;3.7 -2 9;1 3 7] - b=[1 12;6 2;-3.8 7] - c=[1 -1.1 7;3 -9.8 2] + a=[1, 3, -10.2; 3.7, -2, 9; 1, 3, 7] + b=[1, 12; 6, 2; -3.8, 7] + c=[1, -1.1, 7; 3, -9.8, 2] d=0 prompt disp("\nThe solution to the continuous algebraic riccati equation"); @@ -192,9 +192,9 @@ clc disp("Example #2, consider the discrete time state space system:\n"); - a=[1 5 -8.4;1.2 -3 5;1 7 9] - b=[1 5;2 6;-4.4 5] - c=[1 -1.5 2;6 -9.8 1] + a=[1, 5, -8.4; 1.2, -3, 5; 1, 7, 9] + b=[1, 5; 2, 6; -4.4, 5] + c=[1, -1.5, 2; 6, -9.8, 1] d=0 r=eye(columns(b)) prompt @@ -216,7 +216,7 @@ disp("--- Open loop balanced truncation: not yet implemented") elseif (k == 7) disp("SISO pole placement example:") - cmd = "sys=tf2sys(1,[1 -2 1]);"; + cmd = "sys=tf2sys(1, [1, -2, 1]);"; run_cmd disp("System in zero-pole form is:") cmd = "sysout(sys,\"zp\");"; @@ -225,7 +225,7 @@ cmd = "sysout(sys,\"ss\");"; run_cmd disp("Desired poles at -1, -1"); - cmd = "K=place(sys,[-1 -1])"; + cmd = "K=place(sys, [-1, -1])"; run_cmd disp("Check results:") cmd = "[A,B] = sys2ss(sys);";
--- a/scripts/control/bddemo.m +++ b/scripts/control/bddemo.m @@ -95,7 +95,7 @@ help sysappend prompt disp("Consider a double-integrator system:") - sys = tf2sys(1,[1 0 0]); + sys = tf2sys(1, [1, 0, 0]); sys=sysupdate(sys,"ss"); sysout(sys,"ss"); disp("We add a velocity disturbance input as follows:") @@ -145,8 +145,8 @@ disp(" ------------------ ---------------------"); disp(" u_in ->| Discrete system |--->| Continuous system | ---> y_out"); disp(" ------------------ ---------------------"); - sys1 = tf2sys([1 2],[1 2 1], 1,"u_in","y_disc"); - sys2 = tf2sys([1 0],[1 -3 -2],0,"c_in","y_out"); + sys1 = tf2sys([1, 2],[1, 2, 1], 1,"u_in","y_disc"); + sys2 = tf2sys([1, 0],[1, -3, -2],0,"c_in","y_out"); sys = sysmult(sys2,sys1); disp("Consider the hybrid system") sysout(sys); @@ -169,8 +169,8 @@ disp("sysdisc returns dsys=empty since sys has no discrete outputs."); prompt disp("Example block diagram 2:") - sys1 = tf2sys([1 2],[1 2 1], 1,"u_in","y_disc"); - sys2 = tf2sys([1 0],[1 -3 -2],0,"c_in","y_out"); + sys1 = tf2sys([1, 2],[1, 2, 1], 1,"u_in","y_disc"); + sys2 = tf2sys([1, 0],[1, -3, -2],0,"c_in","y_out"); disp(" ---------------------") disp(" u_in -->o-->| Discrete system | --------> y_disc") disp(" ^ --------------------- |") @@ -186,7 +186,7 @@ sys = sysgroup(sys1, sys2); sysout(sys) prompt - sys = sysconnect(sys,[1 2],[2 1]); + sys = sysconnect(sys,[1, 2],[2, 1]); sysout(sys); cmd = "[csys,Acd,Bcd] = syscont(sys);"; run_cmd @@ -208,9 +208,9 @@ disp(" ") prompt disp("Example: combine two SISO systems together:") - cmd = "sys_a=tf2sys([1 2],[3 4]);"; + cmd = "sys_a=tf2sys([1, 2],[3, 4]);"; run_cmd - cmd = "sys_b=tf2sys([5 6],[7 8],1);"; + cmd = "sys_b=tf2sys([5, 6],[7, 8],1);"; run_cmd cmd = "sys_g=sysgroup(sys_a,sys_b);"; run_cmd @@ -234,8 +234,8 @@ disp(" u --->| Bsys |---->| Asys |---> y") disp(" ---------- ----------") disp(" ") - Asys = tf2sys(1,[1 2 1],0,"a_in","a_out"); - Bsys = tf2sys([2 3],[1 3 2],0,"b_in","b_out"); + Asys = tf2sys(1,[1, 2, 1],0,"a_in","a_out"); + Bsys = tf2sys([2, 3],[1, 3, 2],0,"b_in","b_out"); disp("Asys=") sysout(Asys); disp("Bsys="); @@ -249,7 +249,7 @@ disp("when multiplying polynomials"); prompt disp("Example 2: same system, except that Bsys is discrete-time"); - Bsys = tf2sys([2 3],[1 3 2],1e-2,"b_in","b_out"); + Bsys = tf2sys([2, 3],[1, 3, 2],1e-2,"b_in","b_out"); sysout(Bsys); cmd = "sys = sysmult(Asys,Bsys);"; run_cmd @@ -273,8 +273,8 @@ help parallel disp("parallel operates by making a call to sysgroup and sysscale.") disp("Example:") - sys1 = tf2sys(1,[1 1],0,"in1","out1"); - sys2 = tf2sys(2,[1 2],0,"in2","out2"); + sys1 = tf2sys(1,[1, 1],0,"in1","out1"); + sys2 = tf2sys(2,[1, 2],0,"in2","out2"); disp("sys1=") sysout(sys1); disp("sys2=") @@ -291,8 +291,8 @@ out1 = list("y1.1","y1.2"); out2 = list("y2.1","y2.2"); - sys1 = ss2sys([-1,0;0 -2],eye(2),eye(2),[]); - sys2 = ss2sys([-2,0;0 -4],eye(2),eye(2),[]); + sys1 = ss2sys([-1, 0; 0, -2],eye(2),eye(2),[]); + sys2 = ss2sys([-2, 0; 0, -4],eye(2),eye(2),[]); sys1 = syssetsignals(sys1,"in",in1); sys1 = syssetsignals(sys1,"out",out1); @@ -361,11 +361,11 @@ disp("Simple example: P(s) is a first order lag, K(s) is a PI ") disp("controller") nump = 1; - denp = [1 1]; + denp = [1, 1]; disp("P(s)=") tfout(nump,denp) - numk = [1 1]; - denk = [1 0]; + numk = [1, 1]; + denk = [1, 0]; disp("\nK(s)=") tfout(numk,denk); prompt @@ -445,7 +445,7 @@ disp("Notice that PK now has three inputs (input 3 is a duplicate "); prompt("of input 2). Press return to go on") disp("Step 3b: scale input 3 by -1") - cmd = "PK = sysscale(PK,[],diag([1,1,-1]));"; + cmd = "PK = sysscale(PK,[],diag([1, 1, -1]));"; run_cmd disp("PK=") sysout(PK); @@ -455,8 +455,8 @@ disp(" u(t) (output 2) to plant input (input 1)") disp("and prune extraneous inputs/outputs (retain input 2, output 1)") prompt - out_connect = [1 2] - in_connect = [3 1] + out_connect = [1, 2] + in_connect = [3, 1] cmd = "PK0 = sysconnect(PK,out_connect,in_connect);"; run_cmd prompt @@ -536,7 +536,7 @@ disp(" ") disp("Step 1: We've already created systems P and K. Create a sum ") disp("block as follows:") - cmd = "S = ss2sys([],[],[],[1 -1],0,0,0,[],list(""r(t)"",""y(t)""),""e(t)"");"; + cmd = "S = ss2sys([],[],[],[1, -1],0,0,0,[],list(""r(t)"",""y(t)""),""e(t)"");"; run_cmd disp("(You may wish to look at help ss2sys to see what the above does)"); disp("S=") @@ -570,7 +570,7 @@ disp(" ") disp("Step 1: We've already created systems P and K.") disp(" Let us call buildssic:") - disp(" PKcl = buildssic([1 2;2 -1],[],[1],[2],P,K)") + disp(" PKcl = buildssic([1, 2; 2, -1],[],[1],[2],P,K)") disp(" ") disp(" ^ ^ ^ ^ ^ ^") disp(" | | | | | |") @@ -589,7 +589,7 @@ disp(" ") disp(" input list: the only input is 2 (K), positive") disp(" ") - cmd = "PKcl = buildssic([1 2;2 -1],[],[1],[2],P,K);" + cmd = "PKcl = buildssic([1, 2; 2, -1],[],[1],[2],P,K);" run_cmd sysout(PKcl) prompt
--- a/scripts/control/dgkfdemo.m +++ b/scripts/control/dgkfdemo.m @@ -48,15 +48,15 @@ help lqr disp(' ') disp('Example:') - A = [0 1; -2 -1] + A = [0, 1; -2, -1] B = [0; 1] - Q = [1 0; 0 0] + Q = [1, 0; 0, 0] R = 1 disp("Q = state penalty matrix; R = input penalty matrix") prompt disp('Compute state feedback gain k, ARE solution P, and closed-loop') disp('poles as follows:'); - cmd = "[k p e] = lqr(A,B,Q,R)"; + cmd = "[k, p, e] = lqr(A,B,Q,R)"; run_cmd prompt disp("A similar approach can be used for LTI discrete-time systems") @@ -67,19 +67,19 @@ help lqe disp(' ') disp('Example:') - A = [0 1; -2 -1] + A = [0, 1; -2, -1] disp("disturbance entry matrix G") G = eye(2) disp("Output measurement matrix C") - C = [0 1] - SigW = [1 0; 0 1] + C = [0, 1] + SigW = [1, 0; 0, 1] SigV = 1 disp("SigW = input disturbance intensity matrix;") disp("SigV = measurement noise intensity matrix") prompt disp('Compute estimator feedback gain k, ARE solution P, and estimator') disp('poles via the command: ') - cmd = "[k p e] = lqe(A,G,C,SigW,SigV)"; + cmd = "[k, p, e] = lqe(A,G,C,SigW,SigV)"; run_cmd disp("A similar approach can be used for LTI discrete-time systems") disp("by using the dlqe command in place of lqe (see LQG example).") @@ -91,11 +91,11 @@ prompt help lqg disp("Example system") - A = [0 1; .5 .5]; - B = [0 ; 2]; + A = [0, 1; .5, .5]; + B = [0; 2]; G = eye(2) - C = [1 1]; - sys = ss2sys(A,[B G],C); + C = [1, 1]; + sys = ss2sys(A, [B, G], C); sys = syssetsignals(sys,"in", ... ["control input"; "disturbance 1"; "disturbance 2"]); sysout(sys) @@ -110,19 +110,19 @@ cmd = "[K,Q1,P1,Ee,Er] = lqg(sys,SigW,SigV,Q,R,1);"; run_cmd disp("Check: closed loop system A-matrix is") - disp(" [A B*Cc]") - disp(" [Bc*C Ac ]") - cmd = "[Ac,Bc,Cc] = sys2ss(K);"; + disp(" [A, B*Cc]") + disp(" [Bc*C, Ac ]") + cmd = "[Ac, Bc, Cc] = sys2ss(K);"; run_cmd - cmd = "Acl = [A , B*Cc ; Bc*C Ac]"; + cmd = "Acl = [A, B*Cc; Bc*C, Ac]"; run_cmd disp("Check: poles of Acl:") Acl_poles = sortcom(eig(Acl)) disp("Predicted poles from design = union(Er,Ee)") - cmd = "pred_poles = sortcom([Er;Ee])"; + cmd = "pred_poles = sortcom([Er; Ee])"; run_cmd disp("Example 2: discrete-time example") - cmd1 = "Dsys = ss2sys(A,[G B],C,[0 0 0],1);"; + cmd1 = "Dsys = ss2sys(A, [G, B], C, [0, 0, 0], 1);"; cmd2 = "[K,Q1,P1,Ee,Er] = lqg(Dsys,SigW, SigV,Q,R);"; disp("Run commands:") cmd = cmd1; @@ -131,10 +131,10 @@ run_cmd prompt disp("Check: closed loop system A-matrix is") - disp(" [A B*Cc]") - disp(" [Bc*C Ac ]") + disp(" [A, B*Cc]") + disp(" [Bc*C, Ac ]") [Ac,Bc,Cc] = sys2ss(K); - Acl = [A , B*Cc ; Bc*C Ac] + Acl = [A, B*Cc; Bc*C, Ac] prompt disp("Check: poles of Acl:") Acl_poles = sortcom(eig(Acl)) @@ -143,7 +143,7 @@ elseif (menuopt == 4) disp('H2 gain of a system: (Energy in impulse response)') disp('Example 1: Stable plant:') - cmd = "A = [0 1; -2 -1]; B = [0 ; 1]; C = [1 0]; sys_poles = eig(A)"; + cmd = "A = [0, 1; -2, -1]; B = [0; 1]; C = [1, 0]; sys_poles = eig(A)"; run_cmd disp("Put into Packed system form:") cmd = "Asys = ss2sys(A,B,C);"; @@ -160,11 +160,11 @@ title("impulse response of example plant") prompt disp('Example 2: unstable plant') - cmd = "A = [0 1; 2 1]"; + cmd = "A = [0, 1; 2, 1]"; eval(cmd); - cmd = "B = [0 ; 1]"; + cmd = "B = [0; 1]"; eval(cmd); - cmd = "C = [1 0]"; + cmd = "C = [1, 0]"; eval(cmd); cmd = "sys_poles = eig(A)"; run_cmd @@ -195,22 +195,22 @@ disp(" w1(t) w2(t)"); disp(" ") disp("w enters the system through B1, u through B2") - disp("z = [y1 ; y2] is obtained through C1, y=y1 through C2"); + disp("z = [y1; y2] is obtained through C1, y=y1 through C2"); disp(" ") - cmd = "A = [0 1; 0 0]; B1 = [0 0;1 0]; B2 = [0;1];"; + cmd = "A = [0, 1; 0, 0]; B1 = [0, 0; 1, 0]; B2 = [0; 1];"; disp(cmd) eval(cmd); - cmd = "C1 = [1 0; 0 0]; C2 = [1 0]; D11 = zeros(2);"; + cmd = "C1 = [1, 0; 0, 0]; C2 = [1, 0]; D11 = zeros(2);"; disp(cmd) eval(cmd); - cmd = "D12 = [0;1]; D21 = [0 1]; D22 = 0; D = [D11 D12; D21 D22];"; + cmd = "D12 = [0; 1]; D21 = [0, 1]; D22 = 0; D = [D11, D12; D21, D22];"; disp(cmd) eval(cmd); disp("Design objective: compute U(s)=K(s)Y1(s) to minimize the closed") disp("loop impulse response from w(t) =[w1; w2] to z(t) = [y1; y2]"); prompt disp("First: pack system:") - cmd="Asys = ss2sys(A,[B1 B2], [C1;C2] , D);"; + cmd="Asys = ss2sys(A, [B1, B2], [C1; C2], D);"; run_cmd disp("Open loop multivariable Bode plot: (will take a moment)") cmd="bode(Asys);"; @@ -245,7 +245,7 @@ elseif (menuopt == 6) disp('Hinfinity gain of a system: (max gain over all j-omega)') disp('Example 1: Stable plant:') - cmd = "A = [0 1; -2 -1]; B = [0 ; 1]; C = [1 0]; sys_poles = eig(A)"; + cmd = "A = [0, 1; -2, -1]; B = [0; 1]; C = [1, 0]; sys_poles = eig(A)"; run_cmd disp('Pack into system format:') cmd = "Asys = ss2sys(A,B,C);"; @@ -269,7 +269,7 @@ num2str(gmax),"."]) prompt disp('Example 2: unstable plant') - cmd = "A = [0 1; 2 1]; B = [0 ; 1]; C = [1 0]; sys_poles = eig(A)"; + cmd = "A = [0, 1; 2, 1]; B = [0; 1]; C = [1, 0]; sys_poles = eig(A)"; run_cmd disp("Pack into system format:") cmd = "Bsys = ss2sys(A,B,C);"; @@ -287,19 +287,19 @@ prompt disp("Example system: double integrator with output noise and") disp("input disturbance:") - A = [0 1; 0 0] - B1 = [0 0;1 0] - B2 = [0;1] - C1 = [1 0; 0 0] - C2 = [1 0] + A = [0, 1; 0, 0] + B1 = [0, 0; 1, 0] + B2 = [0; 1] + C1 = [1, 0; 0, 0] + C2 = [1, 0] D11 = zeros(2); - D12 = [0;1]; - D21 = [0 1]; + D12 = [0; 1]; + D21 = [0, 1]; D22 = 0; - D = [D11 D12; D21 D22] + D = [D11, D12; D21, D22] prompt disp("First: pack system:") - cmd="Asys = ss2sys(A,[B1 B2], [C1;C2] , D);"; + cmd="Asys = ss2sys(A, [B1, B2], [C1; C2], D);"; run_cmd prompt disp("Open loop multivariable Bode plot: (will take a moment)")
--- a/scripts/control/frdemo.m +++ b/scripts/control/frdemo.m @@ -57,7 +57,7 @@ disp("\nContinuous system bode analysis\n"); disp("Example #1:") disp("\nConsider the system sys1="); - sys1=tf2sys([1 1],[1 0 -1]); + sys1=tf2sys([1, 1], [1, 0, -1]); sysout(sys1); disp("\nPole-zero form can be obtained as follows:") cmd = "sysout(sys1,""zp"");"; @@ -87,7 +87,7 @@ disp("") clc disp("Example #2, sys2=") - cmd = "sys2=zp2sys([1],[-1 -5],10);"; + cmd = "sys2=zp2sys(1, [-1, -5], 10);"; eval(cmd); cmd = "sysout(sys2);"; eval(cmd); @@ -101,7 +101,7 @@ disp("") clc disp("Example #3, Consider the following state space system sys3=:\n"); - cmd = "sys3=ss2sys([0 1; -1000 -1001], [0;1], [0 -891], 1);"; + cmd = "sys3=ss2sys([0, 1; -1000, -1001], [0; 1], [0, -891], 1);"; eval(cmd); cmd = "sysout(sys3);"; eval(cmd); @@ -175,7 +175,7 @@ disp("Display bode plots of a discrete SISO system (dbode)\n") disp("Example #1, Consider the following discrete transfer"); disp(" function:\n"); - cmd = "sys1 = tf2sys([0.00100502 -0.00099502],[1 -2 1],0.001);"; + cmd = "sys1 = tf2sys([0.00100502, -0.00099502], [1, -2, 1], 0.001);"; disp(cmd); eval(cmd); cmd = "sysout(sys1)"; @@ -232,7 +232,7 @@ disp("") clc disp("\nExample #3, Now consider the following state space system:\n"); - cmd = "sys3 = ss2sys([.857 .0011;0 .99930],[1;1],[-.6318 .0057096],5.2, .001);"; + cmd = "sys3 = ss2sys([.857, .0011; 0, .99930],[1;1],[-.6318, .0057096],5.2, .001);"; disp(cmd); eval(cmd); cmd = "sysout(sys3);"; @@ -323,7 +323,7 @@ disp("\nContinuous system nyquist analysis\n"); disp("Display Nyquist plots of a SISO system (nyquist)\n") disp("Example #1, Consider the following transfer function:\n") - cmd = "sys1 = tf2sys([1],[1 0.8 1]);"; + cmd = "sys1 = tf2sys(1, [1, 0.8, 1]);"; disp(cmd); eval(cmd); disp("To examine the transfer function, use the command:"); @@ -376,7 +376,7 @@ disp("") clc disp("\nExample #3, Consider the following state space system:\n") - cmd = "sys3 = ss2sys([0 1 0 0;0 0 1 0;0 0 0 1;0 0 -20 -12],[0;0;0;1],[50 100 0 0],0);"; + cmd = "sys3 = ss2sys([0, 1, 0, 0; 0, 0, 1, 0; 0, 0, 0, 1; 0, 0, -20, -12],[0;0;0;1],[50, 100, 0, 0],0);"; disp(cmd); eval(cmd); disp("\nTo examine the state-space system, use the command:"); @@ -449,7 +449,7 @@ disp(cmd); eval(cmd); disp("\nExample #1, Consider the following transfer function:\n") - cmd = "sys1 = tf2sys([2 -3.4 1.5],[1 -1.6 0.8],T);"; + cmd = "sys1 = tf2sys([2, -3.4, 1.5],[1, -1.6, 0.8],T);"; disp(cmd); eval(cmd); disp("To examine the transfer function, use the command:"); @@ -491,7 +491,7 @@ disp("") clc disp("\nExample #2, Consider the following set of poles and zeros:\n") - cmd = "sys2 = zp2sys([0.98025 + 0.01397i;0.98025 - 0.01397i],[0.96079;0.99005],1,T);"; + cmd = "sys2 = zp2sys([0.98025 + 0.01397i; 0.98025 - 0.01397i],[0.96079;0.99005],1,T);"; disp(cmd); eval(cmd); disp("\nTo examine the open loop zeros and poles, use the command:"); @@ -514,7 +514,7 @@ disp("This example will use the same system used in the third"); disp("example in the continuous nyquist demo. First, that system"); disp("will have to be re-entered useing the following commands:\n"); - cmd = "sys3 = ss2sys([0 1 0 0;0 0 1 0;0 0 0 1;0 0 -20 -12],[0;0;0;1],[50 100 0 0],0);"; + cmd = "sys3 = ss2sys([0, 1, 0, 0; 0, 0, 1, 0; 0, 0, 0, 1; 0, 0, -20, -12],[0;0;0;1],[50, 100, 0, 0],0);"; disp(cmd); eval(cmd); disp("\nTo examine the state-space system, use the command:");
--- a/scripts/control/moddemo.m +++ b/scripts/control/moddemo.m @@ -50,9 +50,9 @@ clc disp('Perform continuous to discrete time conversion (c2d)\n') disp('Example #1, Consider the following continuous time state space system:\n') - a=[0 1;-25 -4] - b=[0;1] - c=[1 1] + a=[0, 1; -25, -4] + b=[0; 1] + c=[1, 1] d=1 prompt disp('\nTo convert this to a discrete time system (using a zero order hold),') @@ -84,9 +84,9 @@ clc disp('Convert from state space to zero / pole form (ss2zp)\n') disp('Example #1, Consider the following state space system:\n') - a=[0 3 1;-2 -4 5;5 8 2] - b=[0;5;2.5] - c=[6 -1.9 2] + a=[0, 3, 1; -2, -4, 5; 5, 8, 2] + b=[0; 5; 2.5] + c=[6, -1.9, 2] d=[-20] prompt disp(' ') @@ -129,9 +129,9 @@ clc disp('Convert from state space to transfer function (ss2tf)\n') disp('Example #1, Consider the following state space system:\n') - a=[0 1;-2 -3] - b=[1;1] - c=[1 9] + a=[0, 1; -2, -3] + b=[1; 1] + c=[1, 9] d=[1] prompt disp('\nTo find an equivalent transfer function for this system, use') @@ -167,8 +167,8 @@ clc disp('Convert from transfer function to zero / pole form (tf2zp)\n') disp('Example #1, Consider the following transfer function:\n') - num=[1 2 3 4 5 ] - den=[1 2 3 4 5 6 7] + num=[1, 2, 3, 4, 5, ] + den=[1, 2, 3, 4, 5, 6, 7] prompt disp('\nTo find the zeros and poles of this system, use the following command:\n') disp('[zer,pol] = tf2zp(num,den)\n')
--- a/scripts/control/sysrepdemo.m +++ b/scripts/control/sysrepdemo.m @@ -32,8 +32,8 @@ page_screen_output = 1; disp('System representation demo:') - num = [5 -1]; - denom = [1 -2 6]; + num = [5, -1]; + denom = [1, -2, 6]; a = b = c = []; syschoice = -1; ch_init = 2; @@ -134,11 +134,11 @@ if(ssopt == 1) disp("Example: construct a system representation of a") disp("double integrator via state-space form") - cmd = "a = [0 1; 0 0];"; + cmd = "a = [0, 1; 0, 0];"; run_cmd - cmd = "b = [0 ; 1];"; + cmd = "b = [0; 1];"; run_cmd - cmd = "c = [1 0];"; + cmd = "c = [1, 0];"; run_cmd cmd = "sys = ss2sys(a,b,c);"; run_cmd @@ -157,11 +157,11 @@ disp("This example is identical to the double-integrator,") disp("except that it is a discrete-time system, and so has") disp("a sampling interval. We arbitrarily select T=1e-3."); - cmd = "a = [0 1; 0 0];"; + cmd = "a = [0, 1; 0, 0];"; run_cmd - cmd = "b = [0 ; 1];"; + cmd = "b = [0; 1];"; run_cmd - cmd = "c = [1 0];"; + cmd = "c = [1, 0];"; run_cmd cmd = "sys=ss2sys(a,b,c,[],1e-3);"; run_cmd @@ -198,7 +198,7 @@ disp("A summing junction that computes e(t) = r(t) - y(t) may be"); disp("constructed as follows:"); disp("First, we set the matrix D:") - cmd = "D = [1 -1];"; + cmd = "D = [1, -1];"; run_cmd disp("ss2sys allows the initialization of signal and state names") disp("(see option 4), so we initialize these as follows:") @@ -251,19 +251,19 @@ disp(" ") disp("For example: the transfer function"); disp(" "); - num = [5 -1]; - denom = [1 -2 6]; + num = [5, -1]; + denom = [1, -2, 6]; tfout(num,denom); disp(" ") disp("is generated by the following commands:") - cmd = "num = [5 -1]"; + cmd = "num = [5, -1]"; run_cmd - cmd = "denom = [1 -2 6]"; + cmd = "denom = [1, -2, 6]"; run_cmd cmd = "sys = tf2sys(num,denom);"; run_cmd disp("alternatively, the system can be generated in a single command:"); - cmd = "sys = tf2sys([5 -1],[1 -2 6]);"; + cmd = "sys = tf2sys([5, -1], [1, -2, 6]);"; run_cmd disp("Notice the output of sys: it is an Octave data structure.") disp("The details of its member variables are explained under") @@ -280,7 +280,7 @@ disp("coefficients of the numerator and denominator polynomials"); disp("Discrete-time transfer functions require ") disp("the additional parameter of a sampling period:") - cmd = "sys=tf2sys([5 -1],[1 2 -6],1e-3);"; + cmd = "sys=tf2sys([5, -1], [1, 2, -6], 1e-3);"; run_cmd cmd = "sysout(sys)"; run_cmd @@ -295,7 +295,7 @@ disp("double-integrator model of aircraft roll dynamics with ") disp("input \"aileron angle\" and output \"theta\". A ") disp("system for this model is generated by the command") - cmd = "aircraft=tf2sys(1,[1 0 0],0,\"aileron angle\",\"theta\");"; run_cmd + cmd = "aircraft=tf2sys(1, [1, 0, 0], 0,\"aileron angle\",\"theta\");"; run_cmd disp("The sampling time parameter 0 indicates that the system") disp("is continuous time. A positive sampling time indicates a") disp("discrete-time system (or sampled data system).") @@ -330,21 +330,21 @@ disp("For example: the transfer function"); disp(" "); k = 5; - num = [5 -1]; - denom = [1 -2 6]; + num = [5, -1]; + denom = [1, -2, 6]; zpout(num,denom,k); disp(" ") disp("is generated by the following commands:") - cmd = "num = [5 -1]"; + cmd = "num = [5, -1]"; run_cmd - cmd = "denom = [1 -2 6]"; + cmd = "denom = [1, -2, 6]"; run_cmd cmd = "k = 5"; run_cmd cmd = "sys = zp2sys(num,denom,k);"; run_cmd disp("alternatively, the system can be generated in a single command:"); - cmd = "sys = zp2sys([5 -1],[1 -2 6],5);"; + cmd = "sys = zp2sys([5, -1],[1, -2, 6],5);"; run_cmd disp("Notice the output of sys: it is an Octave data structure.") disp("The details of its member variables are explained under") @@ -361,7 +361,7 @@ disp("of the system poles and zeros and a scalar leading coefficient."); disp(" ") disp("Discrete-time systems require the additional parameter of a sampling period:") - cmd = "sys=zp2sys([5 -1],[1 2 -6],5,1e-3);"; + cmd = "sys=zp2sys([5, -1],[1, 2, -6],5,1e-3);"; run_cmd cmd = "sysout(sys)"; run_cmd @@ -376,7 +376,7 @@ disp("double-integrator model of aircraft roll dynamics with ") disp("input \"aileron angle\" and output \"theta\". A ") disp("system for this model is generated by the command") - cmd = "aircraft=zp2sys([],[0 0],1,0,\"aileron angle\",\"theta\");"; run_cmd + cmd = "aircraft=zp2sys([],[0, 0],1,0,\"aileron angle\",\"theta\");"; run_cmd disp("The sampling time parameter 0 indicates that the system") disp("is continuous time. A positive sampling time indicates a") disp("discrete-time system (or sampled data system).") @@ -455,7 +455,7 @@ elseif(syschoice== ch_update) disp("The OCST system data structure format will store a system in the same format") disp("as that with which it was initialized. For example, consider the following:") - cmd = "sys=zp2sys([1 2],[3 4 5],6)"; + cmd = "sys=zp2sys([1, 2],[3, 4, 5],6)"; run_cmd disp(" ") disp("Notice the internal variables in the structure include zer, pol, and k,") @@ -473,7 +473,7 @@ elseif(syschoice == ch_view) disp("The sysout command can be used to view a system in any desired format.") disp("For example, consider the system created as follows:") - cmd = "aircraft=zp2sys(1,[0 0],1,0,\"aileron angle\",\"theta\");"; run_cmd + cmd = "aircraft=zp2sys(1,[0, 0],1,0,\"aileron angle\",\"theta\");"; run_cmd disp("The system may be viewed in its default format (zero-pole) as follows") cmd = "sysout(aircraft)"; run_cmd