Mercurial > hg > octave-terminal
changeset 3400:18366d37e7dd
[project @ 1999-12-22 23:36:09 by jwe]
author | jwe |
---|---|
date | Wed, 22 Dec 1999 23:36:14 +0000 |
parents | e665633c76af |
children | 1b782f9cecfe |
files | scripts/ChangeLog scripts/control/DEMOcontrol.m scripts/control/bddemo.m scripts/control/bode.m scripts/control/controldemo.m scripts/control/d2c.m scripts/control/dgkfdemo.m scripts/control/fir2sys.m scripts/control/frdemo.m scripts/control/is_dgkf.m scripts/control/is_stabilizable.m scripts/control/minfo.m scripts/control/moddemo.m scripts/control/polyout.m scripts/control/sysconnect.m scripts/control/sysrepdemo.m scripts/control/tf2sys.m scripts/control/tfout.m scripts/control/tzero.m scripts/control/zp2sys.m scripts/control/zpout.m scripts/image/loadimage.m src/ChangeLog src/lex.l |
diffstat | 24 files changed, 299 insertions(+), 254 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,6 +1,31 @@ 1999-12-22 John W. Eaton <jwe@bevo.che.wisc.edu> + * control/d2c.m: Use double quotes instead of single quotes for + string constants. + * control/dgkfdemo.m: Likewise. + * control/fir2sys.m: Likewise. + * control/frdemo.m: Likewise. + * control/moddemo.m: Likewise. + * control/minfo.m: Likewise. + * control/is_stabilizable.m: Likewise. + * control/is_dgkf.m: Likewise. + * control/polyout.m: Likewise. + * control/sysconnect.m: Likewise. + * control/sysrepdemo.m: Likewise. + * control/tf2sys.m: Likewise. + * control/tfout.m: Likewise. + * control/zp2sys.m: Likewise. + * control/zpout.m: Likewise. + * control/tzero.m: Likewise. + + * control/DEMOcontrol.m: Handle moddemo case too. + + * image/loadimage.m: Use double quotes instead of single quotes + for string constants. Use sprintf instead of square brackets to + construct string. + * control/DEMOcontrol.m: Formatting tweaks. + * control/fir2sys.m: Likewise. 1999-12-17 John W. Eaton <jwe@bevo.che.wisc.edu>
--- a/scripts/control/DEMOcontrol.m +++ b/scripts/control/DEMOcontrol.m @@ -60,6 +60,7 @@ "Block diagram manipulations", "Frequency response functions", "State space analysis functions", + "System model manipulations", "Root locus functions", "LQG/H2/Hinfinity functions", "End"); @@ -70,9 +71,10 @@ case (2) bddemo (); case (3) frdemo (); case (4) analdemo (); - case (5) rldemo (); - case (6) dgkfdemo (); - case (7) return; + case (5) moddemo (); + case (6) rldemo (); + case (7) dgkfdemo (); + case (8) return; endswitch endwhile
--- a/scripts/control/bddemo.m +++ b/scripts/control/bddemo.m @@ -59,7 +59,7 @@ prompt help syssub prompt - disp('Example #1, \n') + disp("Example #1, \n") cmd = "sys1 = tf2sys([1 -1],[1 2 1]);"; run_cmd cmd = "sys2 = tf2sys([1 -1],[1 2 3]);";
--- a/scripts/control/bode.m +++ b/scripts/control/bode.m @@ -186,7 +186,7 @@ if (gnuplot_has_multiplot) subplot(2,1,2); else - prompt('Press any key for phase plot'); + prompt("Press any key for phase plot"); endif axvec = axis2dlim([vec(w),vec(phase)]); axvec(1:2) = wv;
--- a/scripts/control/controldemo.m +++ b/scripts/control/controldemo.m @@ -22,41 +22,6 @@ ## Author: David Clem ## Created: August 15, 1994 -function DEMOcontrol () - - disp(' O C T A V E C O N T R O L S Y S T E M S T O O L B O X') - - while (1) - clc - k = 0; - while (k > 8 || k < 1), - k = menu("Octave Controls System Toolbox Demo", ... - 'System representation', ... - 'Block diagram manipulations ', ... - 'Frequency response functions ', ... - 'State space analysis functions ', ... - 'System model manipulations ', ... - 'Root locus functions ', ... - 'LQG/H2/Hinfinity functions ', ... - 'End'); - - endwhile - if(k == 1) - sysrepdemo - elseif (k == 2) - bddemo - elseif (k == 3) - frdemo - elseif (k == 4) - analdemo - elseif (k == 5) - moddemo - elseif (k == 6) - rldemo - elseif (k == 7) - dgkfdemo - elseif (k == 8) - return - endif - endwhile +function controldemo () + DEMOcontrol (); endfunction
--- a/scripts/control/d2c.m +++ b/scripts/control/d2c.m @@ -174,8 +174,8 @@ for ii=1:rows(Mtop) for jj=1:columns(Mtop) DMall(ii,jj) = Mall(ii,jj) + geps; - GrMall(ii,jj) = norm(Amat - expm(DMall*T),'fro') ... - - norm(Amat-expm(Mall*T),'fro'); + GrMall(ii,jj) = norm (Amat - expm (DMall*T), "fro") ... + - norm (Amat - expm (Mall*T), "fro"); DMall(ii,jj) = Mall(ii,jj); endfor endfor
--- a/scripts/control/dgkfdemo.m +++ b/scripts/control/dgkfdemo.m @@ -30,45 +30,45 @@ page_screen_output = 1; while (1) clc - menuopt=0; - while(menuopt > 10 || menuopt < 1) - menuopt = menu('Octave H2/Hinfinity options demo', ... - 'LQ regulator', ... - 'LG state estimator', ... - 'LQG optimal control design', ... - 'H2 gain of a system', ... - 'H2 optimal controller of a system', ... - 'Hinf gain of a system', ... - 'Hinf optimal controller of a SISO system', ... - 'Hinf optimal controller of a MIMO system', ... - 'Discrete-time Hinf optimal control by bilinear transform', ... - 'Return to main demo menu'); + sel = 0; + while (sel > 10 || sel < 1) + sel = menu ("Octave H2/Hinfinity options demo", + "LQ regulator", + "LG state estimator", + "LQG optimal control design", + "H2 gain of a system", + "H2 optimal controller of a system", + "Hinf gain of a system", + "Hinf optimal controller of a SISO system", + "Hinf optimal controller of a MIMO system", + "Discrete-time Hinf optimal control by bilinear transform", + "Return to main demo menu"); endwhile - if (menuopt == 1) - disp('Linear/Quadratic regulator design:') - disp('Compute optimal state feedback via the lqr command...') + if (sel == 1) + disp("Linear/Quadratic regulator design:") + disp("Compute optimal state feedback via the lqr command...") help lqr - disp(' ') - disp('Example:') + disp(" ") + disp("Example:") A = [0, 1; -2, -1] B = [0; 1] 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:'); + 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)"; run_cmd prompt disp("A similar approach can be used for LTI discrete-time systems") disp("by using the dlqr command in place of lqr (see LQG example).") - elseif (menuopt == 2) - disp('Linear/Gaussian estimator design:') - disp('Compute optimal state estimator via the lqe command...') + elseif (sel == 2) + disp("Linear/Gaussian estimator design:") + disp("Compute optimal state estimator via the lqe command...") help lqe - disp(' ') - disp('Example:') + disp(" ") + disp("Example:") A = [0, 1; -2, -1] disp("disturbance entry matrix G") G = eye(2) @@ -79,16 +79,16 @@ 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: ') + 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)"; 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).") - elseif (menuopt == 3) - disp('LQG optimal controller of a system:') - disp('Input accepted as either A,B,C matrices or in system data structure form') - disp('in both discrete and continuous time.') + elseif (sel == 3) + disp("LQG optimal controller of a system:") + disp("Input accepted as either A,B,C matrices or in system data structure form") + disp("in both discrete and continuous time.") disp("Example 1: continuous time design:") prompt help lqg @@ -142,9 +142,9 @@ Acl_poles = sortcom(eig(Acl)) disp("Predicted poles from design = union(Er,Ee)") pred_poles = sortcom([Er;Ee]) - elseif (menuopt == 4) - disp('H2 gain of a system: (Energy in impulse response)') - disp('Example 1: Stable plant:') + elseif (sel == 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)"; run_cmd disp("Put into Packed system form:") @@ -161,7 +161,7 @@ plot(tt,ht) title("impulse response of example plant") prompt - disp('Example 2: unstable plant') + disp("Example 2: unstable plant") cmd = "A = [0, 1; 2, 1]"; eval(cmd); cmd = "B = [0; 1]"; @@ -171,18 +171,18 @@ cmd = "sys_poles = eig(A)"; run_cmd prompt - disp('Put into system data structure form:') + disp("Put into system data structure form:") cmd="Bsys = ss2sys(A,B,C);"; run_cmd - disp('Evaluate 2-norm:') + disp("Evaluate 2-norm:") cmd = "BsysH2 = h2norm(Bsys)"; run_cmd - disp(' ') - prompt('NOTICE: program returns a value without an error signal.') - disp('') + disp(" ") + prompt("NOTICE: program returns a value without an error signal.") + disp("") - elseif (menuopt == 5) - disp('H2 optimal controller of a system: command = h2syn:') + elseif (sel == 5) + disp("H2 optimal controller of a system: command = h2syn:") prompt help h2syn prompt @@ -244,46 +244,46 @@ prompt disp("Related functions: is_dgkf, is_controllable, is_stabilizable,") disp(" is_observable, is_detectable") - elseif (menuopt == 6) - disp('Hinfinity gain of a system: (max gain over all j-omega)') - disp('Example 1: Stable plant:') + elseif (sel == 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)"; run_cmd - disp('Pack into system format:') + disp("Pack into system format:") cmd = "Asys = ss2sys(A,B,C);"; run_cmd - disp('The infinity norm must be computed iteratively by') - disp('binary search. For this example, we select tolerance tol = 0.01, ') - disp('min gain gmin = 1e-2, max gain gmax=1e4.') - disp('Search quits when upper bound <= (1+tol)*lower bound.') + disp("The infinity norm must be computed iteratively by") + disp("binary search. For this example, we select tolerance tol = 0.01, ") + disp("min gain gmin = 1e-2, max gain gmax=1e4.") + disp("Search quits when upper bound <= (1+tol)*lower bound.") cmd = "tol = 0.01; gmin = 1e-2; gmax = 1e+4;"; run_cmd cmd = "[AsysHinf,gmin,gmax] = hinfnorm(Asys,tol,gmin,gmax)" run_cmd disp("Check: look at max value of magntude Bode plot of Asys:"); [M,P,w] = bode(Asys); - xlabel('Omega') - ylabel('|Asys(j omega)| ') + xlabel("Omega") + ylabel("|Asys(j omega)| ") grid(); semilogx(w,M); disp(["Max magnitude is ",num2str(max(M)), ... ", compared with gmin=",num2str(gmin)," and gmax=", ... num2str(gmax),"."]) prompt - disp('Example 2: unstable plant') + disp("Example 2: unstable plant") 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);"; run_cmd - disp('Evaluate with BsysH2 = hinfnorm(Bsys,tol,gmin,gmax)') + disp("Evaluate with BsysH2 = hinfnorm(Bsys,tol,gmin,gmax)") BsysH2 = hinfnorm(Bsys,tol,gmin,gmax) - disp(' ') - disp('NOTICE: program returns a value without an error signal.') - disp('') + disp(" ") + disp("NOTICE: program returns a value without an error signal.") + disp("") - elseif (menuopt == 7) - disp('Hinfinity optimal controller of a system: command = hinfsyn:') + elseif (sel == 7) + disp("Hinfinity optimal controller of a system: command = hinfsyn:") prompt help hinfsyn prompt @@ -332,19 +332,19 @@ prompt disp("Related functions: is_dgkf, is_controllable, is_stabilizable,") disp(" is_observable, is_detectable, buildssic") - elseif (menuopt == 8) - disp('Hinfinity optimal controller of MIMO system: command = hinfsyn:') + elseif (sel == 8) + disp("Hinfinity optimal controller of MIMO system: command = hinfsyn:") prompt help hinfsyn prompt disp("Example system: Boeing 707-321 airspeed/pitch angle control") disp(" ") hinfdemo - elseif (menuopt == 9) + elseif (sel == 9) disp("Discrete time H-infinity control via bilinear transform"); prompt dhinfdemo - elseif (menuopt == 10) + elseif (sel == 10) return endif prompt
--- a/scripts/control/fir2sys.m +++ b/scripts/control/fir2sys.m @@ -77,22 +77,29 @@ ## Test for the correct number of input arguments if (nargin < 1 | nargin > 4) - usage('sys=fir2sys(num[,tsam,inname,outname])'); + usage ("sys = fir2sys(num [, tsam, inname, outname])"); endif ## let tf2sys do the argument checking den = [1,zeros(1,length(num)-1)]; ## check sampling interval (if any) - if(nargin <= 1) tsam = 1; # default - elseif (isempty(tsam)) tsam = 1; endif + if (nargin <= 1) + tsam = 1; # default + elseif (isempty(tsam)) + tsam = 1; + endif ## Set name of input - if(nargin < 3) inname = sysdefioname(1,"u"); endif + if (nargin < 3) + inname = sysdefioname (1, "u"); + endif ## Set name of output - if(nargin < 4) outname = sysdefioname(1,"y"); endif + if (nargin < 4) + outname = sysdefioname (1, "y"); + endif - sys = tf2sys(num,den,tsam,inname,outname); + sys = tf2sys (num, den, tsam, inname, outname); endfunction
--- a/scripts/control/frdemo.m +++ b/scripts/control/frdemo.m @@ -33,11 +33,11 @@ j = 0; while (j != 4) disp(""); - j = menu("Octave Controls Systems Toolbox Frequency Response Demo",... - 'Bode analysis (bode)',... - 'Nyquist analysis (nyquist)',... - "Nichols analysis (nichols)", ... - 'Return to main demo menu'); + j = menu("Octave Controls Systems Toolbox Frequency Response Demo", + "Bode analysis (bode)", + "Nyquist analysis (nyquist)", + "Nichols analysis (nichols)", + "Return to main demo menu"); if (j == 1) k1 = 0; @@ -45,11 +45,11 @@ disp("\n"); clc - k1 = menu("Bode analysis (bode)",... - 'Continuous system bode analysis',... - 'Discrete system bode analysis',... - 'Bode command description', ... - 'Return to frdemo menu'); + k1 = menu("Bode analysis (bode)", + "Continuous system bode analysis", + "Discrete system bode analysis", + "Bode command description", + "Return to frdemo menu"); if( k1 == 1 ) disp(" ") @@ -147,7 +147,7 @@ eval(cmd); disp("\nNotice that there are now 2 inputs and 2 outputs, and that it did"); disp("not matter what form the two systems were in when they were grouped."); - disp(["\nTo view the system\'s bode plots, execute the",... + disp(["\nTo view the system's bode plots, execute the", " following command:\n"]) cmd = "bode(sys_mimo);"; run_cmd; @@ -311,11 +311,11 @@ disp("") clc; - k2 = menu("Nyquist analysis (Nyquist)",... - 'Continuous system nyquist analysis',... - 'Discrete system nyquist analysis',... - 'Mixed system nyquist analysis',... - 'Return to frdemo menu'); + k2 = menu("Nyquist analysis (Nyquist)", + "Continuous system nyquist analysis", + "Discrete system nyquist analysis", + "Mixed system nyquist analysis", + "Return to frdemo menu"); if( k2 == 1 ) disp("")
--- a/scripts/control/is_dgkf.m +++ b/scripts/control/is_dgkf.m @@ -151,7 +151,7 @@ [A,B,C,D] = sys2ss(Asys); ## scale input/output for numerical reasons - if(norm(C,'fro')*norm(B,'fro') == 0) + if(norm (C, "fro") * norm (B, "fro") == 0) error("||C||*||B|| = 0; no dynamic connnection from inputs to outputs"); endif xx = sqrt(norm(B, Inf) / norm(C, Inf));
--- a/scripts/control/is_stabilizable.m +++ b/scripts/control/is_stabilizable.m @@ -75,7 +75,7 @@ ## now use an ordered Schur decomposition to get an orthogonal ## basis of the unstable subspace... n = rows(a); - [ua,s] = schur(-(a+eye(n)*tol),'A'); + [ua, s] = schur (-(a+eye(n)*tol), "A"); k = sum( real(eig(a)) >= 0 ); # count unstable poles if( k > 0 )
--- a/scripts/control/minfo.m +++ b/scripts/control/minfo.m @@ -39,7 +39,7 @@ warning("minfo: obsolete. Use sys2ss, sys2tf, or sys2zp."); if (nargin ~= 1 ) - disp('MINFO: Wrong number of arguments') + disp ("MINFO: Wrong number of arguments") systype = nout = nin = ncstates = ndstates = []; endif
--- a/scripts/control/moddemo.m +++ b/scripts/control/moddemo.m @@ -33,173 +33,173 @@ while (1) clc - disp('Octave Model Manipulations Demo') - disp('=======================================') - disp(' 1) Perform continuous to discrete time conversion (c2d)') - disp(' 2) Convert from state space to zero / pole form (ss2zp)') - disp(' Convert from zero / pole to state space form (zp2ss)') - disp(' 3) Convert from state space to transfer function form (ss2tf)') - disp(' Convert from transfer function to state space form (tf2ss)') - disp(' 4) Convert from transfer function to zero / pole form (tf2zp)') - disp(' Convert from zero / pole to transfer function form (zp2tf)') - disp(' 5) Return to main demo menu') - disp(' ') + disp("Octave Model Manipulations Demo") + disp("=======================================") + disp(" 1) Perform continuous to discrete time conversion (c2d)") + disp(" 2) Convert from state space to zero / pole form (ss2zp)") + disp(" Convert from zero / pole to state space form (zp2ss)") + disp(" 3) Convert from state space to transfer function form (ss2tf)") + disp(" Convert from transfer function to state space form (tf2ss)") + disp(" 4) Convert from transfer function to zero / pole form (tf2zp)") + disp(" Convert from zero / pole to transfer function form (zp2tf)") + disp(" 5) Return to main demo menu") + disp(" ") k=6; while(k > 5 || k < 1) - k = input('Please enter a number:'); + k = input("Please enter a number:"); endwhile if (k == 1) clc - disp('Perform continuous to discrete time conversion (c2d)\n') - disp('Example #1, Consider the following continuous time state space system:\n') + 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] d=1 prompt - disp('\nTo convert this to a discrete time system (using a zero order hold),') - disp('use the following commands:\n') + disp("\nTo convert this to a discrete time system (using a zero order hold),") + disp("use the following commands:\n") cmd="sys=ss2sys(a,b,c,d);"; run_cmd cmd="dsys = c2d(sys,0.2);"; run_cmd cmd="sysout(dsys);"; run_cmd - disp('Function check\n') - disp('Check the poles of sys vs dsys:\n') + disp("Function check\n") + disp("Check the poles of sys vs dsys:\n") cmd="[da,db]=sys2ss(dsys);"; run_cmd cmd="lam = eig(a);"; run_cmd - disp('Discretize the continuous time eigenvalues using the matrix exponential:\n') - disp('lambc = exp(lam*0.2)\n') + disp("Discretize the continuous time eigenvalues using the matrix exponential:\n") + disp("lambc = exp(lam*0.2)\n") lambc = exp(lam*0.2) - disp('Check the eigenvalues of da\n') + disp("Check the eigenvalues of da\n") lambd = eig(da) - disp('Calculate the difference between lambd and lambc:\n') - cmd = 'error = sort(lambd)-sort(lambc)\n'; + disp("Calculate the difference between lambd and lambc:\n") + cmd = "error = sort(lambd)-sort(lambc)\n"; run_cmd disp("The error is on the order of roundoff noise, so we're o.k.") prompt clc elseif (k == 2) clc - disp('Convert from state space to zero / pole form (ss2zp)\n') - disp('Example #1, Consider the following state space system:\n') + 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] d=[-20] prompt - disp(' ') - disp('\nTo find the poles and zeros of this sytstem, use the following command:\n') - disp('\n[zer, pol] = ss2zp(a, b, c, d)\n') + disp(" ") + disp("\nTo find the poles and zeros of this sytstem, use the following command:\n") + disp("\n[zer, pol] = ss2zp(a, b, c, d)\n") prompt - disp('Results:\n') + disp("Results:\n") [zer, pol] = ss2zp(a, b, c, d) - disp('Variable Description:\n') - disp('zer, pol => zeros and poles of the state space system') - disp('a, b, c, d => state space system\n') + disp("Variable Description:\n") + disp("zer, pol => zeros and poles of the state space system") + disp("a, b, c, d => state space system\n") prompt clc - disp('Convert from zero / pole to state space form (zp2ss)\n') - disp('Example #1, Consider the following set of zeros and poles:\n') + disp("Convert from zero / pole to state space form (zp2ss)\n") + disp("Example #1, Consider the following set of zeros and poles:\n") zer pol prompt - disp('\nTo find an equivalent state space representation for this set of poles') - disp('and zeros, use the following commands:\n') + disp("\nTo find an equivalent state space representation for this set of poles") + disp("and zeros, use the following commands:\n") k=1 - disp('\n[na, nb, nc, nd] = zp2ss(zer, pol, k)\n') + disp("\n[na, nb, nc, nd] = zp2ss(zer, pol, k)\n") prompt - disp('Results:\n') + disp("Results:\n") [na, nb, nc, nd] = zp2ss(zer, pol, k) - disp('Variable Description:\n') - disp('na, nb, nc, nd => state space system equivalent to zero / pole input') - disp('zer, pol => zeros and poles of desired state space system') - disp('k => gain associated with the zeros\n') + disp("Variable Description:\n") + disp("na, nb, nc, nd => state space system equivalent to zero / pole input") + disp("zer, pol => zeros and poles of desired state space system") + disp("k => gain associated with the zeros\n") prompt - disp('Function check\n') - disp('Are the eigenvalues of the origonal state space system the same as the') - disp('eigenvalues of the newly constructed state space system ?\n') - disp('Find the difference between the two sets of eigenvalues') - disp('error = sort(eig(a)) - sort(eig(na))\n') + disp("Function check\n") + disp("Are the eigenvalues of the origonal state space system the same as the") + disp("eigenvalues of the newly constructed state space system ?\n") + disp("Find the difference between the two sets of eigenvalues") + disp("error = sort(eig(a)) - sort(eig(na))\n") error = sort(eig(a)) - sort(eig(na)) prompt clc elseif (k == 3) clc - disp('Convert from state space to transfer function (ss2tf)\n') - disp('Example #1, Consider the following state space system:\n') + 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] d=[1] prompt - disp('\nTo find an equivalent transfer function for this system, use') - disp('the following command:\n') - disp('[num, den] = ss2tf(a, b, c, d)\n') + disp("\nTo find an equivalent transfer function for this system, use") + disp("the following command:\n") + disp("[num, den] = ss2tf(a, b, c, d)\n") prompt - disp('Results:\n') + disp("Results:\n") [num,den] = ss2tf(a, b, c, d) - disp('Variable Description:\n') - disp('num, den => numerator and denominator of transfer function that is') - disp(' equivalent to the state space system') - disp('a, b, c, d => state space system\n') + disp("Variable Description:\n") + disp("num, den => numerator and denominator of transfer function that is") + disp(" equivalent to the state space system") + disp("a, b, c, d => state space system\n") prompt clc - disp('Convert from transfer function to state space form (tf2ss)\n') - disp('Example #1, Consider the following transfer function:\n') + disp("Convert from transfer function to state space form (tf2ss)\n") + disp("Example #1, Consider the following transfer function:\n") num den prompt - disp('\nTo find an equivalent state space representation for this system, use') - disp('the following command:\n') - disp('[a, b, c, d] = tf2ss(num, den)\n') + disp("\nTo find an equivalent state space representation for this system, use") + disp("the following command:\n") + disp("[a, b, c, d] = tf2ss(num, den)\n") prompt - disp('Results:\n') + disp("Results:\n") [a, b, c, d] = tf2ss(num, den) - disp('Variable Description:\n') - disp('a, b, c, d => state space system equivalent to transfer function input') - disp('num, den => numerator and denominator of transfer function that is equivalent') - disp(' to the state space system\n') + disp("Variable Description:\n") + disp("a, b, c, d => state space system equivalent to transfer function input") + disp("num, den => numerator and denominator of transfer function that is equivalent") + disp(" to the state space system\n") prompt clc elseif (k == 4) clc - disp('Convert from transfer function to zero / pole form (tf2zp)\n') - disp('Example #1, Consider the following transfer function:\n') + 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] prompt - disp('\nTo find the zeros and poles of this system, use the following command:\n') - disp('[zer,pol] = tf2zp(num,den)\n') + disp("\nTo find the zeros and poles of this system, use the following command:\n") + disp("[zer,pol] = tf2zp(num,den)\n") prompt - disp('Results:\n') + disp("Results:\n") [zer,pol] = tf2zp(num,den) - disp('Variable Description:\n') - disp('zer,pol => zeros and poles of the transfer function') - disp('num, den => numerator and denominator of transfer function\n') + disp("Variable Description:\n") + disp("zer,pol => zeros and poles of the transfer function") + disp("num, den => numerator and denominator of transfer function\n") prompt clc - disp('Convert from zero / pole to transfer function (zp2tf)\n') - disp('Example #1, Consider the following set of zeros and poles:\n') + disp("Convert from zero / pole to transfer function (zp2tf)\n") + disp("Example #1, Consider the following set of zeros and poles:\n") zer pol prompt - disp('\nTo find an equivalent transfer function representation for this set') - disp('of poles and zeros, use the following commands:\n') + disp("\nTo find an equivalent transfer function representation for this set") + disp("of poles and zeros, use the following commands:\n") k=1 - disp('\n[num, den] = zp2tf(zer, pol, k)\n') + disp("\n[num, den] = zp2tf(zer, pol, k)\n") prompt - disp('Results:\n') + disp("Results:\n") [num, den] = zp2tf(zer, pol, k) - disp('Variable Description:\n') - disp('[num, den] => transfer function representation of desired set of zeros') - disp(' and poles') - disp('a, b, c, d => state space system') - disp('zer, pol => zeros and poles of desired state space system') - disp('k => gain associated with the zeros\n') + disp("Variable Description:\n") + disp("[num, den] => transfer function representation of desired set of zeros") + disp(" and poles") + disp("a, b, c, d => state space system") + disp("zer, pol => zeros and poles of desired state space system") + disp("k => gain associated with the zeros\n") prompt clc elseif (k == 5)
--- a/scripts/control/polyout.m +++ b/scripts/control/polyout.m @@ -44,7 +44,7 @@ endif if (nargin == 1) - x = 's'; + x = "s"; elseif( ! isstr(x) ) error("polyout: second argument must be a string"); endif @@ -57,8 +57,8 @@ else tmp = num2str(c(1)); endif for ii=2:n - if(real(c(ii)) < 0) ns = ' - '; c(ii) = -c(ii); - else ns = ' + '; endif + if(real(c(ii)) < 0) ns = " - "; c(ii) = -c(ii); + else ns = " + "; endif if( imag(c(ii)) ) nstr = sprintf("(%s)",com2str(c(ii)) ); else nstr = num2str(c(ii)); endif
--- a/scripts/control/sysconnect.m +++ b/scripts/control/sysconnect.m @@ -127,7 +127,7 @@ output_list = reshape(output_list,1,length(output_list)); ## make sure we're in state space form - sys = sysupdate(sys,'ss'); + sys = sysupdate (sys, "ss"); ## permute rows and columns of B,C,D matrices into pseudo-dgkf form... all_inputs = sysreorder(mm,input_list); @@ -268,8 +268,10 @@ endfor ## maintain original system type if it was SISO - if (strcmp(sysgettype(sys),"tf") ) sysupdate(sys,'tf'); - elseif(strcmp(sysgettype(sys),"zp") ) sysupdate(sys,'zp'); + if (strcmp (sysgettype (sys), "tf")) + sysupdate (sys, "tf"); + elseif (strcmp (sysgettype (sys),"zp")) + sysupdate (sys, "zp"); endif endfunction
--- a/scripts/control/sysrepdemo.m +++ b/scripts/control/sysrepdemo.m @@ -30,7 +30,7 @@ save_val = page_screen_output; page_screen_output = 1; - disp('System representation demo:') + disp("System representation demo:") num = [5, -1]; denom = [1, -2, 6]; a = b = c = []; @@ -43,7 +43,7 @@ ch_quit = ch_details+1; while(syschoice != ch_quit) disp(" ") - syschoice = menu('Octave System Representation Menu', ... + syschoice = menu("Octave System Representation Menu", ... "General overview of system representation (DO THIS FIRST)", ... "Initialize a system (ss2sys, tf2sys, zp2sys)", ... "Extract data from a system(sys2ss, sys2tf, sys2zp, etc.)", ... @@ -54,11 +54,11 @@ if(syschoice == 1) # general overview disp("The Octave Control Systems Toolbox (OCST) was designed to") disp("provide a simple user interface to a powerful set of tools.") - disp(' ') - disp(' ----------') - disp(' input(s) ---->| System | ---> output(s) ') - disp(' ----------') - disp(' ') + disp(" ") + disp(" ----------") + disp(" input(s) ---->| System | ---> output(s) ") + disp(" ----------") + disp(" ") disp("Like other computer-aided control system design tools, the OCST") disp("enables users to enter their descriptions of dynamic systems in ") disp("their preferred form (state space, transfer function, or "); @@ -101,7 +101,7 @@ disp("OCST package will be quite easy to use.") elseif(syschoice == ch_init) % Initialize disp("Initialization of a system:"); - disp(' '); + disp(" "); formopt = 0; while(formopt != 4) disp("Three data formats may be used to initialize a system:") @@ -111,15 +111,15 @@ "zero-pole form (zp2sys)", ... "Return to System representation menu"); if(formopt == 1) - disp('State space representation of a system is based on the usual') - disp('multi-variable differential equations') - disp(' ') - disp(' . ') - disp(' x = A x + B u -or - x(k+1) = A x(k) + B u(k) ') - disp(' y = C x + D u y(k) = C x(k) + D u(k) ') - disp(' ') - disp('for matrices A, B, C, D of appropriate dimension.') - disp(' ') + disp("State space representation of a system is based on the usual") + disp("multi-variable differential equations") + disp(" ") + disp(" . ") + disp(" x = A x + B u -or - x(k+1) = A x(k) + B u(k) ") + disp(" y = C x + D u y(k) = C x(k) + D u(k) ") + disp(" ") + disp("for matrices A, B, C, D of appropriate dimension.") + disp(" ") ssopt = 0; ssquit = 5; while(ssopt < ssquit)
--- a/scripts/control/tf2sys.m +++ b/scripts/control/tf2sys.m @@ -59,16 +59,16 @@ ## Test for the correct number of input arguments if ((nargin < 2) || (nargin > 5)) - usage('outsys=tf2sys(num,den[,tsam,inname,outname])'); + usage ("outsys = tf2sys (num, den [, tsam, inname, outname])"); return endif ## check input format if( ! ( (is_vector(num) || is_scalar(num)) && ... (is_vector(den) || is_scalar(den))) ) - error(['num (',num2str(rows(num)),'x',num2str(columns(num)), ... - ') and den (',num2str(rows(den)),'x',num2str(columns(den)), ... - ') must be vectors']) + error(["num (",num2str(rows(num)),"x",num2str(columns(num)), ... + ") and den (",num2str(rows(den)),"x",num2str(columns(den)), ... + ") must be vectors"]) endif ## strip leading zero coefficients @@ -83,7 +83,7 @@ if(nargin <= 2) tsam = 0; # default elseif (isempty(tsam)) tsam = 0; endif if ( (! (is_scalar(tsam) && (imag(tsam) == 0) )) || (tsam < 0) ) - error('tsam must be a positive real scalar') + error("tsam must be a positive real scalar") endif outsys.num = num;
--- a/scripts/control/tfout.m +++ b/scripts/control/tfout.m @@ -42,7 +42,7 @@ endif if (nargin == 2) - x = 's'; + x = "s"; elseif( ! isstr(x) ) error("tfout: third argument must be a string"); endif @@ -56,7 +56,7 @@ disp(y) disp(denomstring) else - error('tfout: empty transfer function') + error ("tfout: empty transfer function") end empty_list_elements_ok = save_empty;
--- a/scripts/control/tzero.m +++ b/scripts/control/tzero.m @@ -79,7 +79,7 @@ ## problem balancing method (Hodel and Tiller, Linear Alg. Appl., 1992) Asys = zgpbal(Asys); [A,B,C,D] = sys2ss(Asys); # balance coefficients - meps = 2*eps*norm([A, B; C, D],'fro'); + meps = 2*eps*norm ([A, B; C, D], "fro"); Asys = zgreduce(Asys,meps); [A, B, C, D] = sys2ss(Asys); # ENVD algorithm if(!isempty(A)) ## repeat with dual system
--- a/scripts/control/zp2sys.m +++ b/scripts/control/zp2sys.m @@ -77,7 +77,7 @@ endif if (! is_scalar(k)) - error('k must be a scalar'); + error("k must be a scalar"); endif ## Test proper numbers of poles and zeros. The number of poles must be
--- a/scripts/control/zpout.m +++ b/scripts/control/zpout.m @@ -46,7 +46,7 @@ endif if (nargin == 3) - x = 's'; + x = "s"; elseif( ! isstr(x) ) error("zpout: third argument must be a string"); endif @@ -100,7 +100,7 @@ disp(denomstring) endif else - error('zpout: empty transfer function') + error ("zpout: empty transfer function") end empty_list_elements_ok = save_empty;
--- a/scripts/image/loadimage.m +++ b/scripts/image/loadimage.m @@ -45,7 +45,7 @@ ## The file is assumed to have variables img and map, or X and map. - eval (['load ', file]); + eval (sprintf ("load %s", file)); if (exist ("img")) img_retval = img;
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +1999-12-22 John W. Eaton <jwe@bevo.che.wisc.edu> + + * lex.l (Vwarn_single_quote_string): New variable. + (syms_of_lex): DEFVAR it. + (warn_single_quote_string): New function. + (gripe_single_quote_string): New function. + Use new stuff to allow warnings for code that uses single quote + characters to introduce string constants. + 1999-12-20 John W. Eaton <jwe@bevo.che.wisc.edu> * mkbuiltins: Add #undef quad to generated file.
--- a/src/lex.l +++ b/src/lex.l @@ -165,6 +165,8 @@ static bool Vwarn_separator_insert = false; +static bool Vwarn_single_quote_string = false; + // Forward declarations for functions defined at the bottom of this // file. @@ -189,6 +191,7 @@ static yum_yum eat_whitespace (void); static yum_yum eat_continuation (void); static void maybe_warn_separator_insert (char sep); +static void gripe_single_quote_string (void); %} @@ -1755,6 +1758,10 @@ yylval.tok_val = new token (s); token_stack.push (yylval.tok_val); + + if (delim == '\'') + gripe_single_quote_string (); + return TEXT; } } @@ -2217,6 +2224,22 @@ } } +static void +gripe_single_quote_string (void) +{ + string nm = curr_fcn_file_full_name; + + if (Vwarn_single_quote_string) + { + if (nm.empty ()) + warning ("single quote delimited string near line %d", + input_line_number); + else + warning ("single quote delimited string near line %d of file %s", + input_line_number, nm.c_str ()); + } +} + static int warn_separator_insert (void) { @@ -2226,6 +2249,14 @@ } static int +warn_single_quote_string (void) +{ + Vwarn_single_quote_string = check_preference ("warn_single_quote_string"); + + return 0; +} + +static int whitespace_in_literal_matrix (void) { int pref = 0; @@ -2252,6 +2283,10 @@ "print warning if commas or semicolons that might be inserted\n\ automatically in literal matrices"); + DEFVAR (warn_single_quote_string, 0.0, warn_single_quote_string, + "print warning if a signle quote character is used to introduce a\n\ + string constant"); + DEFVAR (whitespace_in_literal_matrix, "", whitespace_in_literal_matrix, "control auto-insertion of commas and semicolons in literal matrices"); }