Mercurial > hg > octave-avbm
changeset 4771:b8105302cfe8
[project @ 2004-02-16 17:45:50 by jwe]
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,40 @@ +2004-02-16 A S Hodel <a.s.hodel@Eng.Auburn.EDU> + + * control/base/__bodquist__.m, control/base/__stepimp__.m, + control/base/analdemo.m, control/base/bddemo.m, + control/base/bode.m, control/base/dre.m, control/base/frdemo.m, + control/base/lqg.m, control/base/nyquist.m, control/base/place.m, + control/base/rldemo.m, control/base/rlocus.m, + control/base/tzero.m, control/hinf/dgkfdemo.m, + control/hinf/dhinfdemo.m, control/hinf/h2syn.m, + control/hinf/hinf_ctr.m, control/hinf/hinfsyn.m, + control/hinf/wgt1o.m, control/obsolete/dlqg.m, + control/obsolete/packsys.m, control/obsolete/series.m, + control/system/__sysdefioname__.m, + control/system/__sysdefstname__.m, control/system/__sysgroupn__.m, + control/system/__tf2sysl__.m, control/system/buildssic.m, + control/system/c2d.m, control/system/d2c.m, + control/system/dmr2d.m, control/system/fir2sys.m, + control/system/is_signal_list.m, control/system/is_siso.m, + control/system/jet707.m, control/system/listidx.m, + control/system/moddemo.m, control/system/ord2.m, + control/system/packedform.m, control/system/parallel.m, + control/system/ss2sys.m, control/system/sys2tf.m, + control/system/sys2zp.m, control/system/sysadd.m, + control/system/sysappend.m, control/system/sysconnect.m, + control/system/syscont.m, control/system/sysdimensions.m, + control/system/sysdisc.m, control/system/sysdup.m, + control/system/sysgetsignals.m, control/system/sysgettype.m, + control/system/sysgroup.m, control/system/sysmin.m, + control/system/sysmult.m, control/system/sysprune.m, + control/system/sysrepdemo.m, control/system/sysscale.m, + control/system/syssetsignals.m, control/system/syssub.m, + control/system/sysupdate.m, control/system/tf2sys.m, + control/system/ugain.m, control/system/zp2ss.m, + control/system/zp2sys.m, control/util/__outlist__.m, + control/util/__zgpbal__.m, control/util/strappend.m: + Use cell arrays instead of lists. + 2004-01-23 Stefan van der Walt <stefan@sun.ac.za> * plot/bar.m: Increase size of cutoff vector from xlen-1 to xlen
--- a/scripts/control/base/__bodquist__.m +++ b/scripts/control/base/__bodquist__.m @@ -87,7 +87,7 @@ ## SISO state space systems to zero-pole form if( is_siso(sys) & strcmp( sysgettype(sys), "ss") ) [zer,pol,k,tsam,inname,outname] = sys2zp(sys); - sys = zp2sys(zer,pol,k,tsam,inname,outname); + sys = zp(zer,pol,k,tsam,inname,outname); endif ## get system frequency response
--- a/scripts/control/base/__stepimp__.m +++ b/scripts/control/base/__stepimp__.m @@ -228,7 +228,7 @@ gm = zeros(NOUT, 1); tt = "impulse"; else - ssys = ss2sys(F, G, C, D, t_step); + ssys = ss(F, G, C, D, t_step); gm = dcgain(ssys); tt = "step"; endif
--- a/scripts/control/base/analdemo.m +++ b/scripts/control/base/analdemo.m @@ -113,7 +113,7 @@ clc disp("Example #2, consider the state space system from example 1 again:"); - cmd = "sys = ss2sys(a,b,c,d);"; + cmd = "sys = ss(a,b,c,d);"; disp(cmd); eval(cmd); sysout(sys); @@ -137,7 +137,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 = ss([-11, 6; -15, 8], [1; 2], [2, -1], 0);"; eval(cmd); disp(cmd); disp("Examine the poles and zeros of the continuous system:"); @@ -218,7 +218,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=tf(1, [1, -2, 1]);"; run_cmd disp("System in zero-pole form is:") cmd = "sysout(sys,\"zp\");";
--- a/scripts/control/base/bddemo.m +++ b/scripts/control/base/bddemo.m @@ -60,9 +60,9 @@ help syssub prompt disp("Example #1, \n") - cmd = "sys1 = tf2sys([1 -1],[1 2 1]);"; + cmd = "sys1 = tf([1 -1],[1 2 1]);"; run_cmd - cmd = "sys2 = tf2sys([1 -1],[1 2 3]);"; + cmd = "sys2 = tf([1 -1],[1 2 3]);"; run_cmd disp("sys1=") sysout(sys1); @@ -96,7 +96,7 @@ help sysappend prompt disp("Consider a double-integrator system:") - sys = tf2sys(1, [1, 0, 0]); + sys = tf(1, [1, 0, 0]); sys=sysupdate(sys,"ss"); sysout(sys,"ss"); disp("We add a velocity disturbance input as follows:") @@ -119,14 +119,14 @@ a = rand(3,3); b = rand(3,2); c = rand(2,3); - sys = ss2sys(a,b,c); + sys = ss(a,b,c); sysout(sys); prompt disp("Change state names to larry, moe, and curly as follows:") - cmd = "sys = syssetsignals(sys,\"st\",list(\"larry\",\"moe \" , \"curly\"));"; + cmd = 'sys = syssetsignals(sys,"st",{"larry","moe" , "curly"});'; run_cmd disp("Indicate that output 2 is discrete-time:") - cmd = "sys = syssetsignals(sys,\"yd\",1,2);"; + cmd = 'sys = syssetsignals(sys,"yd",1,2);'; run_cmd disp("Change output 2 name to \"Vir\""); cmd = "sys = syssetsignals(sys,\"out\",\"Vir\",2);"; @@ -146,8 +146,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 = tf([1, 2],[1, 2, 1], 1,"u_in","y_disc"); + sys2 = tf([1, 0],[1, -3, -2],0,"c_in","y_out"); sys = sysmult(sys2,sys1); disp("Consider the hybrid system") sysout(sys); @@ -170,8 +170,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 = tf([1, 2],[1, 2, 1], 1,"u_in","y_disc"); + sys2 = tf([1, 0],[1, -3, -2],0,"c_in","y_out"); disp(" ---------------------") disp(" u_in -->o-->| Discrete system | --------> y_disc") disp(" ^ --------------------- |") @@ -209,9 +209,9 @@ disp(" ") prompt disp("Example: combine two SISO systems together:") - cmd = "sys_a=tf2sys([1, 2],[3, 4]);"; + cmd = "sys_a=tf([1, 2],[3, 4]);"; run_cmd - cmd = "sys_b=tf2sys([5, 6],[7, 8],1);"; + cmd = "sys_b=tf([5, 6],[7, 8],1);"; run_cmd cmd = "sys_g=sysgroup(sys_a,sys_b);"; run_cmd @@ -235,8 +235,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 = tf(1,[1, 2, 1],0,"a_in","a_out"); + Bsys = tf([2, 3],[1, 3, 2],0,"b_in","b_out"); disp("Asys=") sysout(Asys); disp("Bsys="); @@ -250,7 +250,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 = tf([2, 3],[1, 3, 2],1e-2,"b_in","b_out"); sysout(Bsys); cmd = "sys = sysmult(Asys,Bsys);"; run_cmd @@ -274,8 +274,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 = tf(1,[1, 1],0,"in1","out1"); + sys2 = tf(2,[1, 2],0,"in2","out2"); disp("sys1=") sysout(sys1); disp("sys2=") @@ -287,13 +287,13 @@ prompt disp("parallel can be used for multiple input systems as well:") - in1 = list("u1.1","u1.2"); - in2 = list("u2.1","u2.2"); - out1 = list("y1.1","y1.2"); - out2 = list("y2.1","y2.2"); + in1 = {"u1.1","u1.2"}; + in2 = {"u2.1","u2.2"}; + out1 = {"y1.1","y1.2"}; + out2 = {"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 = ss([-1, 0; 0, -2],eye(2),eye(2),[]); + sys2 = ss([-2, 0; 0, -4],eye(2),eye(2),[]); sys1 = syssetsignals(sys1,"in",in1); sys1 = syssetsignals(sys1,"out",out1); @@ -371,8 +371,8 @@ tfout(numk,denk); prompt disp("We'll show three approaches. ") - P = tf2sys(nump,denp,0,"plant input","plant output"); - K = tf2sys(numk, denk,0,"controller input","controller output"); + P = tf(nump,denp,0,"plant input","plant output"); + K = tf(numk, denk,0,"controller input","controller output"); meth = 0; while(meth != 5) @@ -410,14 +410,14 @@ disp("Step 1: put plants in system format:"); nump denp - cmd = "P = tf2sys(nump,denp,0,""plant input"",""plant output"");"; + cmd = "P = tf(nump,denp,0,""plant input"",""plant output"");"; run_cmd disp("P=") sysout(P) prompt numk denk - cmd = "K = tf2sys(numk, denk,0,""controller input"",""controller output"");"; + cmd = "K = tf(numk, denk,0,""controller input"",""controller output"");"; run_cmd sysout(K) prompt @@ -537,9 +537,9 @@ 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 = ss([],[],[],[1, -1],0,0,0,[],{"r(t)", "y(t)"},"e(t)");'; run_cmd - disp("(You may wish to look at help ss2sys to see what the above does)"); + disp("(You may wish to look at help ss to see what the above does)"); disp("S=") sysout(S) disp("notice that this is just a gain block that outputs e = r - y")
--- a/scripts/control/base/bode.m +++ b/scripts/control/base/bode.m @@ -163,7 +163,7 @@ xlabel(xlstr); if(is_siso(sys)) subplot(2,1,1); - title(["|[Y/U]",tistr,"|, u=", nth(inname,1),", y=",nth(outname,1)]); + title(["|[Y/U]",tistr,"|, u=", inname{1},", y=",outname{1}]); else title([ "||Y(", tistr, ")/U(", tistr, ")||"]); disp("MIMO plot from") @@ -197,7 +197,7 @@ xlabel(xlstr); ylabel("Phase in deg"); title([ "phase([Y/U]", tistr, ... - "), u=", nth(inname,1),", y=",nth(outname,1)]); + "), u=", inname{1},", y=",outname{1}]); grid("on"); semilogx(w,phase); ## This should be the default for subsequent plot commands.
--- a/scripts/control/base/dre.m +++ b/scripts/control/base/dre.m @@ -77,12 +77,12 @@ ## @item tvals ## time values at which @var{p}(@var{t}) is computed ## @item plist -## list values of @var{p}(@var{t}); nth (@var{plist}, @var{ii}) +## list values of @var{p}(@var{t}); @var{plist} { @var{ii} } ## is @var{p}(@var{tvals}(@var{ii})). ## ## @item tvals ## @example -## is selected so that || nth(Plist,ii) - nth(Plist,ii-1) || < Ptol +## is selected so that || Plist{ii} - Plist{ii-1} || < Ptol ## for ii=2:length(tvals) ## @end example ## @end table @@ -146,13 +146,13 @@ maxerr = 0; ## compute new values of P(t); recompute old values just in case for ii=2:tvlen - uv_i_minus_1 = [ In ; nth(Plist,ii-1) ]; + uv_i_minus_1 = [ In ; Plist{ii-1} ]; delta_t = tvals(ii-1) - tvals(ii); uv = expm(-H*delta_t)*uv_i_minus_1; Qi = uv(n1:n2,1:nn)/uv(1:nn,1:nn); Plist(ii) = (Qi+Qi')/2; ## check error - Perr = norm(nth(Plist,ii) - nth(Plist,ii-1))/norm(nth(Plist,ii)); + Perr = norm(Plist{ii} - Plist{ii-1})/norm(Plist{ii}); maxerr = max(maxerr,Perr); if(Perr > Ptol) new_t = mean(tvals([ii,ii-1]));
--- a/scripts/control/base/frdemo.m +++ b/scripts/control/base/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=tf([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=zp(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=ss([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 = tf([0.00100502, -0.00099502], [1, -2, 1], 0.001);"; disp(cmd); eval(cmd); cmd = "sysout(sys1)"; @@ -214,7 +214,7 @@ clc disp("Example #2, Consider the following set of discrete poles and"); disp("zeros:\n") - cmd = "sys2 = zp2sys([0.99258;0.99745],[0.99961;0.99242],1,0.001);"; + cmd = "sys2 = zp([0.99258;0.99745],[0.99961;0.99242],1,0.001);"; disp(cmd); eval(cmd); cmd = "sysout(sys2)"; @@ -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 = ss([.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 = tf(1, [1, 0.8, 1]);"; disp(cmd); eval(cmd); disp("To examine the transfer function, use the command:"); @@ -360,7 +360,7 @@ disp("") clc disp("Example #2, Consider the following set of poles and zeros:\n") - cmd = "sys2 = zp2sys([-1;-4],[-2+1.4142i;-2-1.4142i],1);"; + cmd = "sys2 = zp([-1;-4],[-2+1.4142i;-2-1.4142i],1);"; disp(cmd); eval(cmd); disp("\nTo examine the poles and zeros, 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 = ss([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 = tf([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 = zp([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 = ss([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/base/lqg.m +++ b/scripts/control/base/lqg.m @@ -106,10 +106,10 @@ ", columns(R)=", num2str(columns(R))]); endif - varname = list("Sigw","Sigv","Q","R"); + varname = {"Sigw","Sigv","Q","R"}; for kk=1:length(varname); - eval(sprintf("chk = issquare(%s);",nth(varname,kk))); - if(! chk ) error("lqg: %s is not square",nth(varname,kk)); endif + eval(sprintf("chk = issquare(%s);",varname{kk})); + if(! chk ) error("lqg: %s is not square",varname{kk}); endif endfor ## permute (if need be) @@ -149,9 +149,9 @@ inname1 = strappend(outname,"_K"); if(DIG) - K = ss2sys(Ac,Bc,Cc,Dc,tsam,n,nz,stname1,inname1,outname1,1:rows(Cc)); + K = ss(Ac,Bc,Cc,Dc,tsam,n,nz,stname1,inname1,outname1,1:rows(Cc)); else - K = ss2sys(Ac,Bc,Cc,Dc,tsam,n,nz,stname,inname1,outname1); + K = ss(Ac,Bc,Cc,Dc,tsam,n,nz,stname,inname1,outname1); endif endfunction
--- a/scripts/control/base/nyquist.m +++ b/scripts/control/base/nyquist.m @@ -146,7 +146,7 @@ [stn, inn, outn] = sysgetsignals(sys); if(is_siso(sys)) title(sprintf("Nyquist plot from %s to %s, w (rad/s) in [%e, %e]", ... - nth(inn,1), nth(outn,1), w(1), w(length(w))) ) + inn{1}, outn{1}, w(1), w(length(w))) ) endif gset nologscale xy;
--- a/scripts/control/base/place.m +++ b/scripts/control/base/place.m @@ -51,7 +51,7 @@ ## check arguments if(!isstruct(sys)) - error("sys must be in system data structure format (see ss2sys)"); + error("sys must be in system data structure format (see ss)"); endif sys = sysupdate(sys,"ss"); # make sure it has state space form up to date if(!is_controllable(sys))
--- a/scripts/control/base/rldemo.m +++ b/scripts/control/base/rldemo.m @@ -44,7 +44,7 @@ clc disp("Display continuous system's open loop poles and zeros (pzmap)\n"); disp("Example #1, Consider the following continuous transfer function:"); - cmd = "sys1 = tf2sys([1.5, 18.5, 6], [1, 4, 155, 302, 5050]);"; + cmd = "sys1 = tf([1.5, 18.5, 6], [1, 4, 155, 302, 5050]);"; disp(cmd); eval(cmd); cmd ="sysout(sys1);"; @@ -61,7 +61,7 @@ clc disp("Example #2, Consider the following set of poles and zeros:"); - cmd = "sys2 = zp2sys([-1, 5, -23],[-1, -10, -7+5i, -7-5i],5);"; + cmd = "sys2 = zp([-1, 5, -23],[-1, -10, -7+5i, -7-5i],5);"; disp(cmd); eval(cmd); cmd = "sysout(sys2);"; @@ -76,7 +76,7 @@ clc disp("Example #3, Consider the following state space system:\n"); - cmd = "sys3=ss2sys([0, 1; -10, -11], [0; 1], [0, -2], 1);"; + cmd = "sys3=ss([0, 1; -10, -11], [0; 1], [0, -2], 1);"; disp(cmd); eval(cmd); cmd = "sysout(sys3);"; @@ -105,7 +105,7 @@ cmd = "Tsam = 1;"; run_cmd; disp("Example #1, Consider the following discrete transfer function:"); - cmd = "sys1 = tf2sys([1.05, -0.09048], [1, -2, 1],Tsam);"; + cmd = "sys1 = tf([1.05, -0.09048], [1, -2, 1],Tsam);"; disp(cmd); eval(cmd); cmd ="sysout(sys1);"; @@ -122,7 +122,7 @@ clc disp("Example #2, Consider the following set of discrete poles and zeros:"); - cmd = "sys2 = zp2sys(-0.717, [1, -0.368], 3.68, Tsam);"; + cmd = "sys2 = zp(-0.717, [1, -0.368], 3.68, Tsam);"; disp(cmd); eval(cmd); cmd = "sysout(sys2);"; @@ -137,7 +137,7 @@ clc disp("Example #3, Consider the following discrete state space system:\n"); - cmd = "sys3=ss2sys([1, 0.0952; 0, 0.905], [0.00484; 0.0952], [1, 0], 0, Tsam);"; + cmd = "sys3=ss([1, 0.0952; 0, 0.905], [0.00484; 0.0952], [1, 0], 0, Tsam);"; disp(cmd); eval(cmd); cmd = "sysout(sys3);"; @@ -163,7 +163,7 @@ clc disp("Display root locus of a continuous SISO system (rlocus)\n") disp("Example #1, Consider the following continuous transfer function:"); - cmd = "sys1 = tf2sys([1.5, 18.5, 6],[1, 4, 155, 302, 5050]);"; + cmd = "sys1 = tf([1.5, 18.5, 6],[1, 4, 155, 302, 5050]);"; disp(cmd); eval(cmd); cmd ="sysout(sys1);"; @@ -186,7 +186,7 @@ clc disp("Example #2, Consider the following set of poles and zeros:"); - cmd = "sys2 = zp2sys([],[0, -20, -2, -0.1],5);"; + cmd = "sys2 = zp([],[0, -20, -2, -0.1],5);"; disp(cmd); eval(cmd); cmd = "sysout(sys2);"; @@ -201,7 +201,7 @@ clc disp("Example #3, Consider the following state space system:\n"); - cmd = "sys3=ss2sys([0, 1; -10, -11], [0; 1], [0, -2], 0);"; + cmd = "sys3=ss([0, 1; -10, -11], [0; 1], [0, -2], 0);"; disp(cmd); eval(cmd); cmd = "sysout(sys3);"; @@ -233,7 +233,7 @@ cmd = "Tsam = 1;"; run_cmd; disp("Example #1, Consider the following discrete transfer function:"); - cmd = "sys1 = tf2sys([1.05, -0.09048],[1, -2, 1],Tsam);"; + cmd = "sys1 = tf([1.05, -0.09048],[1, -2, 1],Tsam);"; disp(cmd); eval(cmd); cmd ="sysout(sys1);"; @@ -256,7 +256,7 @@ clc disp("Example #2, Consider the following set of discrete poles and zeros:"); - cmd = "sys2 = zp2sys(-0.717, [1, -0.368], 3.68, Tsam);"; + cmd = "sys2 = zp(-0.717, [1, -0.368], 3.68, Tsam);"; disp(cmd); eval(cmd); cmd = "sysout(sys2);"; @@ -273,7 +273,7 @@ clc disp("Example #3, Consider the following discrete state space system:\n"); - cmd = "sys3=ss2sys([1, 0.0952; 0, 0.905], [0.00484; 0.0952], [1, 0], 0, Tsam);"; + cmd = "sys3=ss([1, 0.0952; 0, 0.905], [0.00484; 0.0952], [1, 0], 0, Tsam);"; disp(cmd); eval(cmd); cmd = "sysout(sys3);";
--- a/scripts/control/base/rlocus.m +++ b/scripts/control/base/rlocus.m @@ -191,7 +191,7 @@ axis(axlim); [stn,inname,outname] = sysgetsignals(sys); xlabel(sprintf("Root locus from %s to %s, gain=[%f,%f]: Real axis", ... - nth(inname,1),nth(outname,1),gvec(1),gvec(ngain))); + inname{1}, outname{1},gvec(1),gvec(ngain))); ylabel("Imag. axis"); plot(real(rlpolv),imag(rlpolv),".1;locus points;", ...
--- a/scripts/control/base/tzero.m +++ b/scripts/control/base/tzero.m @@ -54,7 +54,7 @@ ## get A,B,C,D and Asys variables, regardless of initial form if(nargin == 4) - Asys = ss2sys(A,B,C,D); + Asys = ss(A,B,C,D); elseif( (nargin == 1) && (! isstruct(A))) usage("[zer,gain] = tzero(A,B,C,D) or zer = tzero(Asys)"); elseif(nargin != 1) @@ -83,10 +83,10 @@ Asys = zgreduce(Asys,meps); [A, B, C, D] = sys2ss(Asys); # ENVD algorithm if(!isempty(A)) ## repeat with dual system - Asys = ss2sys(A', C', B', D'); Asys = zgreduce(Asys,meps); + Asys = ss(A', C', B', D'); Asys = zgreduce(Asys,meps); ## transform back - [A,B,C,D] = sys2ss(Asys); Asys = ss2sys(A', C', B', D'); + [A,B,C,D] = sys2ss(Asys); Asys = ss(A', C', B', D'); endif zer = []; # assume none
--- a/scripts/control/hinf/dgkfdemo.m +++ b/scripts/control/hinf/dgkfdemo.m @@ -27,7 +27,7 @@ function dgkfdemo () save_val = page_screen_output; - page_screen_output = 1; + page_screen_output = 0; while (1) clc sel = 0; @@ -97,7 +97,7 @@ B = [0; 2]; G = eye(2) C = [1, 1]; - sys = ss2sys(A, [B, G], C); + sys = ss(A, [B, G], C); sys = syssetsignals(sys,"in", ... ["control input"; "disturbance 1"; "disturbance 2"]); sysout(sys) @@ -124,7 +124,7 @@ 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 = ss(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; @@ -148,7 +148,7 @@ 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);"; + cmd = "Asys = ss(A,B,C);"; run_cmd disp("Evaluate system 2-norm (impulse response energy):"); cmd = "AsysH2 = h2norm(Asys)"; @@ -172,7 +172,7 @@ run_cmd prompt disp("Put into system data structure form:") - cmd="Bsys = ss2sys(A,B,C);"; + cmd="Bsys = ss(A,B,C);"; run_cmd disp("Evaluate 2-norm:") cmd = "BsysH2 = h2norm(Bsys)"; @@ -212,7 +212,7 @@ 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 = ss(A, [B1, B2], [C1; C2], D);"; run_cmd disp("Open loop multivariable Bode plot: (will take a moment)") cmd="bode(Asys);"; @@ -250,7 +250,7 @@ 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);"; + cmd = "Asys = ss(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, ") @@ -274,7 +274,7 @@ 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);"; + cmd = "Bsys = ss(A,B,C);"; run_cmd disp("Evaluate with BsysH2 = hinfnorm(Bsys,tol,gmin,gmax)") BsysH2 = hinfnorm(Bsys,tol,gmin,gmax) @@ -301,7 +301,7 @@ D = [D11, D12; D21, D22] prompt disp("First: pack system:") - cmd="Asys = ss2sys(A, [B1, B2], [C1; C2], D);"; + cmd="Asys = ss(A, [B1, B2], [C1; C2], D);"; run_cmd prompt disp("Open loop multivariable Bode plot: (will take a moment)")
--- a/scripts/control/hinf/dhinfdemo.m +++ b/scripts/control/hinf/dhinfdemo.m @@ -88,7 +88,7 @@ ww = vec(logspace(-4.99, 3.99, 100)); disp("Create ZOH equivalent model of a continuous plant"); -cmd = "G = tf2sys(2,[1 3 2]); Gd = c2d(G, Ts);"; +cmd = "G = tf(2,[1 3 2]); Gd = c2d(G, Ts);"; run_cmd ## w-plane (continuous representation of the sampled system)
--- a/scripts/control/hinf/h2syn.m +++ b/scripts/control/hinf/h2syn.m @@ -28,7 +28,7 @@ ## @strong{Inputs} input system is passed as either ## @table @var ## @item asys -## system data structure (see ss2sys, sys2ss) +## system data structure (see ss, sys2ss) ## @itemize @bullet ## @item controller is implemented for continuous time systems ## @item controller is NOT implemented for discrete time systems @@ -117,8 +117,8 @@ nn = ncstates + ndstates; In = eye(nn); KA = A + Bu*F2 + L2*Cy; - Kc1 = ss2sys(AF2,Bw,CzF2,zeros(nz,nw)); - Kf1 = ss2sys(AL2,BwL2,F2,zeros(nu,nw)); + Kc1 = ss(AF2,Bw,CzF2,zeros(nz,nw)); + Kf1 = ss(AL2,BwL2,F2,zeros(nu,nw)); g1 = h2norm(Kc1); g2 = h2norm(Kf1); @@ -132,7 +132,7 @@ Kout = strappend(Ain((nin-nu+1):(nin)),"_K"); ## compute systems for return - K = ss2sys(KA,-L2/Ru,Ry\F2,zeros(nu,ny),Atsam,ncstates,ndstates,Kst,Kin,Kout); + K = ss(KA,-L2/Ru,Ry\F2,zeros(nu,ny),Atsam,ncstates,ndstates,Kst,Kin,Kout); endif if (nargout > 2) @@ -148,7 +148,7 @@ nz = rows (Cz); nw = columns (Bw); - Kc = ss2sys(AF2, In, CzF2, zeros(nz,nn), Atsam, ... + Kc = ss(AF2, In, CzF2, zeros(nz,nn), Atsam, ... ncstates, ndstates, stname2, inname2, outname2); endif @@ -162,7 +162,7 @@ ## fix system state estimator output names outname3 = strappend(Ast,"_est"); - Kf = ss2sys(AL2, BwL2, In, zeros(nn,nw),Atsam, ... + Kf = ss(AL2, BwL2, In, zeros(nn,nw),Atsam, ... ncstates, ndstates, stname3, inname3,outname3); endif
--- a/scripts/control/hinf/hinf_ctr.m +++ b/scripts/control/hinf/hinf_ctr.m @@ -139,6 +139,6 @@ endif - K = ss2sys(ahat,bhat(:,1:ny),chat(1:nu,:),dhat(1:nu,1:ny)); + K = ss(ahat,bhat(:,1:ny),chat(1:nu,:),dhat(1:nu,1:ny)); endfunction
--- a/scripts/control/hinf/hinfsyn.m +++ b/scripts/control/hinf/hinfsyn.m @@ -22,7 +22,7 @@ ## @strong{Inputs} input system is passed as either ## @table @var ## @item asys -## system data structure (see ss2sys, sys2ss) +## system data structure (see ss, sys2ss) ## @itemize @bullet ## @item controller is implemented for continuous time systems ## @item controller is NOT implemented for discrete time systems (see @@ -171,28 +171,28 @@ printf("--------------------------------------\n"); ## set up error messages - errmesg = list(" o o o o o ", ... + errmesg = {" o o o o o ", ... " # - - - - ", ... " o # - - - ", ... " o o # - - ", ... " o o o # - ", ... " o o o o # ", ... - " - - - - - "); - errdesx = list("", ... + " - - - - - "}; + errdesx = {"", ... "X im eig.", ... "Hx not Ham.", ... "X inf.eig", ... "X not symm.", ... "X not pos", ... - "R singular"); + "R singular"}; - errdesy = list(" ", ... + errdesy = {" ", ... "Y im eig.", ... "Hy not Ham.", ... "Y inf.eig", ... "Y not symm.", ... "Y not pos", ... - "Rtilde singular"); + "Rtilde singular"}; ## now do the search @@ -233,15 +233,15 @@ endif if(x_ha_err >= 0 & x_ha_err <= 6) - printf("%s",nth(errmesg,x_ha_err+1)); - xerr = nth(errdesx,x_ha_err+1); + printf("%s",errmesg{x_ha_err+1}); + xerr = errdesx{x_ha_err+1}; else error(" *** Xinf fail: this should never happen!"); endif if(y_ha_err >= 0 & y_ha_err <= 6) - printf("%s",nth(errmesg,y_ha_err+1)); - yerr = nth(errdesy,y_ha_err+1); + printf("%s",errmesg{y_ha_err+1}); + yerr = errdesy{y_ha_err+1}; else error(" *** Yinf fail: this should never happen!"); endif @@ -298,7 +298,7 @@ Kin = strappend(Aout((nout-ny+1):(nout)),"_K"); Kout = strappend(Ain((nin-nu+1):(nin)),"_K"); [Ac, Bc, Cc, Dc] = sys2ss(K); - K = ss2sys(Ac,Bc,Cc,Dc,Atsam,ncstates,ndstates,Kst,Kin,Kout); + K = ss(Ac,Bc,Cc,Dc,Atsam,ncstates,ndstates,Kst,Kin,Kout); if (nargout >= 3) GW = starp(Asys, K); endif
--- a/scripts/control/hinf/wgt1o.m +++ b/scripts/control/hinf/wgt1o.m @@ -55,5 +55,5 @@ endif d=[vh]; - wsys = ss2sys(a,b,c,d); + wsys = ss(a,b,c,d); endfunction
--- a/scripts/control/obsolete/dlqg.m +++ b/scripts/control/obsolete/dlqg.m @@ -118,7 +118,7 @@ Bc = Ke; Cc = -Ks; Dc = zeros(rows(Cc),columns(Bc)); - K = ss2sys(Ac,Bc,Cc,Dc,1); + K = ss(Ac,Bc,Cc,Dc,1); disp("HODEL: need to add names to this guy!") endfunction
--- a/scripts/control/obsolete/packsys.m +++ b/scripts/control/obsolete/packsys.m @@ -16,7 +16,7 @@ ## along with Octave; see the file COPYING. If not, write to the Free ## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. -## O B S O L E T E: use ss2sys instead. +## O B S O L E T E: use ss instead. ## function Asys = packsys(a,b,c[,d,dflg]) ## ## dflg: 0 for continuous time system, 1 for discrete-time system. @@ -34,7 +34,7 @@ function Asys = packsys (a, b, c, d, dflg) - warning("packsys is obsolete! Use ss2sys instead."); + warning("packsys is obsolete! Use ss instead."); if (nargin < 3 || nargin > 5) disp("packsys: Invalid number of arguments") @@ -66,6 +66,6 @@ error("packsys: incompatible dimensions") endif - Asys = ss2sys(a,b,c,d,dflg); + Asys = ss(a,b,c,d,dflg); endfunction
--- a/scripts/control/obsolete/series.m +++ b/scripts/control/obsolete/series.m @@ -90,7 +90,7 @@ ## take care of mu output if(muflag == 1) - a=ss2sys(a,b,c,d); + a=ss(a,b,c,d); b=c=d=0; endif endif
--- a/scripts/control/system/__sysdefioname__.m +++ b/scripts/control/system/__sysdefioname__.m @@ -25,7 +25,7 @@ ## used internally, minimal argument checking ## ## @strong{Example} @code{ioname = __sysdefioname__(5,"u",3)} -## returns the list: +## returns the cell array: ## @example ## ioname = ## ( @@ -44,11 +44,11 @@ if (nargin == 2) m = min(1,n); endif - ioname = list(); + ioname = {}; jj = 1; if(n > 0 & m > 0 & m <= n) for ii = m:n - ioname(ii+1-m) = sprintf("%s_%d",str,ii); + ioname{ii+1-m} = sprintf("%s_%d",str,ii); endfor elseif(m > n) error("str=%s; start value m=%d > final value n=%d",str,m,n);
--- a/scripts/control/system/__sysdefstname__.m +++ b/scripts/control/system/__sysdefstname__.m @@ -25,17 +25,17 @@ function stname = __sysdefstname__ (n, nz) - stname = list (); + stname = {}; if (n > 0) for ii = 1:n - stname(ii) = sprintf ("x_%d", ii); + stname{ii} = sprintf ("x_%d", ii); endfor endif ## Set default names for discrete states if (nz > 0) for ii = (n+1):(n+nz) - stname(ii) = sprintf ("xd_%d", ii); + stname{ii} = sprintf ("xd_%d", ii); endfor endif
--- a/scripts/control/system/__sysgroupn__.m +++ b/scripts/control/system/__sysgroupn__.m @@ -35,16 +35,16 @@ l = length(names); ii = 1; while(ii <= l-1) - st1 = nth(names,ii); + st1 = names{ii}; jj = ii+1; while ( jj <= l) - st2 = nth(names,jj); + st2 = names{jj}; if(strcmp(st1,st2)) suffix = ["_",num2str(jj)]; warning("sysgroup: %s name(%d) = %s name(%d) = %s", ... kind,ii,kind,jj,st1); strval = sprintf("%s%s",st2,suffix); - names(jj) = strval; + names{jj} = strval; warning("sysgroup: changed %s name %d to %s",kind,jj,strval); ## restart the check (just to be sure there's no further duplications) ii = 0; jj = l;
--- a/scripts/control/system/__tf2sysl__.m +++ b/scripts/control/system/__tf2sysl__.m @@ -24,12 +24,6 @@ function vec = __tf2sysl__ (vec) - while (length (vec) > 1 && vec(1) == 0) - vec = vec (2:end); - endwhile - - if (vec(1) == 0) - warning ("tf2sys: polynomial has no nonzero coefficients!") - endif + error("__tf2sysl__ no longer used; use the tf function."); endfunction
--- a/scripts/control/system/buildssic.m +++ b/scripts/control/system/buildssic.m @@ -150,12 +150,12 @@ nt = n + nz; endif for ii = 6:nargin - eval(["ss = s", num2str(ii-4), ";"]); - if (!isstruct(ss)) + eval(["mysys = s", num2str(ii-4), ";"]); + if (!isstruct(mysys)) error("---> Parameter must be a structed system."); endif - ss = sysupdate(ss, "ss"); - [n1, nz1, m1, p1] = sysdimensions(ss); + mysys = sysupdate(mysys, "ss"); + [n1, nz1, m1, p1] = sysdimensions(mysys); if (n1 && nz1) error("---> cannot handle mixed continuous and discrete systems."); endif @@ -163,11 +163,11 @@ if (n1) error("---> cannot handle mixed cont. and discr. systems."); endif - if (tsam != sysgettsam(ss)) + if (tsam != sysgettsam(mysys)) error("---> sampling time of all systems must match."); endif endif - [as,bs,cs,ds] = sys2ss(ss); + [as,bs,cs,ds] = sys2ss(mysys); nt1 = n1 + nz1; if (!nt1) ## pure gain (pad B, C with zeros) @@ -295,6 +295,6 @@ Dnew(:,ii) = sign(iu)*D(:,abs(iu)); endfor - sys = ss2sys(A, Bnew, C, Dnew, tsam, n, nz); + sys = ss(A, Bnew, C, Dnew, tsam, n, nz); endfunction
--- a/scripts/control/system/c2d.m +++ b/scripts/control/system/c2d.m @@ -153,7 +153,7 @@ innames = sysgetsignals(sys,"in"); outnames = sysgetsignals(sys,"out"); outlist = 1:p; - dsys = ss2sys(aa,bb,cc,dd,T,0,n+nz,stnames,innames, ... + dsys = ss(aa,bb,cc,dd,T,0,n+nz,stnames,innames, ... outnames,outlist); ## rename states for ii=1:n @@ -175,7 +175,7 @@ C = tk*(c/(IT-a)); D = d + (c*iab); stnamed = strappend(stname,"_d"); - dsys = ss2sys(A,B,C,D,T,0,rows(A),stnamed,inname,outname); + dsys = ss(A,B,C,D,T,0,rows(A),stnamed,inname,outname); endif elseif(strcmp(opt,"matched")) if(is_digital(sys)) @@ -192,8 +192,8 @@ endfor ## Should the freaquency we adjust around always be 1? [cmag,cphase,cw] = bode(sys,1); - [dmag,dpahse,dw] = bode(zp2sys(z,p,1,T),1); - dsys = zp2sys(z,p,cmag/dmag,T); + [dmag,dpahse,dw] = bode(zp(z,p,1,T),1); + dsys = zp(z,p,cmag/dmag,T); endif else error ("invalid option = %s", opt);
--- a/scripts/control/system/d2c.m +++ b/scripts/control/system/d2c.m @@ -106,7 +106,7 @@ C = tk*(c/(I+a)); D = d- (c*iab); stnamec = strappend(stname,"_c"); - csys = ss2sys(A,B,C,D,0,rows(A),0,stnamec,inname,outname); + csys = ss(A,B,C,D,0,rows(A),0,stnamec,inname,outname); elseif(strcmp(opt,"log")) sys = sysupdate(sys,"ss"); [n,nz,m,p] = sysdimensions(sys); @@ -209,7 +209,7 @@ if(!isempty(b)) bb = Mall(1:na,(na+1):(na+nb)); endif - csys = ss2sys(aa,bb,cc,dd,0,na,0,stnam,innam,outnam); + csys = ss(aa,bb,cc,dd,0,na,0,stnam,innam,outnam); ## update names nn = sysdimensions(sys);
--- a/scripts/control/system/dmr2d.m +++ b/scripts/control/system/dmr2d.m @@ -141,12 +141,12 @@ ## find states whose name begins with any strings in sprefix. ns = length(sprefix); for kk=1:ns - spk = nth(sprefix,kk); # get next prefix and length + spk = sprefix{kk}; # get next prefix and length spl = length(spk); ## check each state name for ii=1:nz - sti = nth(stname,ii); # compare spk with this state name + sti = stname{ii}; # compare spk with this state name if(length(sti) >= spl) ## if the prefix matches and ii isn't already in the list, add ii if(strcmp(sti(1:spl),spk) & !any(fidx == ii) ) @@ -242,7 +242,7 @@ else b1b = [b1b, b1w]; # append new inputs newin = strappend(innamenz,["_d",num2str(kk-1)]); - inname = append(inname,newin); + inname = __sysconcat__(inname,newin); endif endfor @@ -258,6 +258,6 @@ stname = stname(pvi); ## construct new system and return - dsys = ss2sys(da,db,dc,dd,Ts2,0,nz,stname,inname,outname,find(yd == 1)); + dsys = ss(da,db,dc,dd,Ts2,0,nz,stname,inname,outname,find(yd == 1)); endfunction
--- a/scripts/control/system/fir2sys.m +++ b/scripts/control/system/fir2sys.m @@ -80,7 +80,7 @@ usage ("sys = fir2sys(num [, tsam, inname, outname])"); endif - ## let tf2sys do the argument checking + ## let tf do the argument checking den = [1,zeros(1,length(num)-1)]; ## check sampling interval (if any) @@ -100,6 +100,6 @@ outname = __sysdefioname__ (1, "y"); endif - sys = tf2sys (num, den, tsam, inname, outname); + sys = tf (num, den, tsam, inname, outname); endfunction
--- a/scripts/control/system/is_signal_list.m +++ b/scripts/control/system/is_signal_list.m @@ -1,4 +1,4 @@ -## Copyright (C) 1996, 1998, 2000 Auburn University. All rights reserved. +## Copyright (C) 1996, 1998, 2000, 2004 Auburn University. All rights reserved. ## ## This file is part of Octave. ## @@ -23,11 +23,13 @@ function flg = is_signal_list (mylist) - flg = islist (mylist); - + flg = iscell (mylist); + if(flg) + flg = (rows(mylist) == 1 | columns(mylist) == 1); + end if (flg) for ii = 1:length (mylist) - if (! (isstr (nth (mylist, ii)) && rows (nth (mylist,ii)) == 1)) + if (! (isstr (mylist{ii}) && rows (mylist{ii}) == 1)) flg = 0; endif endfor
--- a/scripts/control/system/is_siso.m +++ b/scripts/control/system/is_siso.m @@ -30,7 +30,7 @@ if (nargin != 1) usage ("SISO = is_siso (sys)"); elseif (! isstruct (sys)) - error ("input must be a system structure (see ss2sys, tf2sys, zp2sys)"); + error ("input must be a system structure (see ss, tf, zp)"); endif [n, nz, m, p] = sysdimensions (sys);
--- a/scripts/control/system/jet707.m +++ b/scripts/control/system/jet707.m @@ -52,6 +52,6 @@ inam = ["thrust"; "rudder"]; onam = ["speed"; "pitch"]; snam = ["x1"; "x2"; "x3"; "x4"]; - outsys = ss2sys(a, b, c, d, 0.0, 4, 0, snam, inam, onam); + outsys = ss(a, b, c, d, 0.0, 4, 0, snam, inam, onam); endfunction
--- a/scripts/control/system/listidx.m +++ b/scripts/control/system/listidx.m @@ -34,6 +34,7 @@ ## @end deftypefn function [idxvec,errmsg] = listidx(listvar,strlist) + error("listidx: don't use this anymore, ok?\n"); if(nargin != 2) usage("idxvec = listidx(listvar,strlist)"); @@ -73,12 +74,12 @@ nsigs = length(listvar); for idx = 1:length(strlist) - signame = nth(strlist,idx); + signame = strlist{idx}; for jdx = 1:nsigs - if( strcmp(signame,nth(listvar,jdx)) ) + if( strcmp(signame,listvar{jdx}) ) if(idxvec(idx) != 0) warning("Duplicate signal name %s (%d,%d)\n", ... - nth(listvar,jdx),jdx,idxvec(idx)); + listvar{jdx},jdx,idxvec(idx)); else idxvec(idx) = jdx; endif
--- a/scripts/control/system/moddemo.m +++ b/scripts/control/system/moddemo.m @@ -55,7 +55,7 @@ prompt 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);"; + cmd="sys=ss(a,b,c,d);"; run_cmd cmd="dsys = c2d(sys,0.2);"; run_cmd
--- a/scripts/control/system/ord2.m +++ b/scripts/control/system/ord2.m @@ -62,5 +62,5 @@ endif w = 2.0 * pi * nfreq; - outsys = ss2sys([-2.0*w*damp, -w; w, 0], [w; 0], [0, gain]); + outsys = ss ([-2.0*w*damp, -w; w, 0], [w; 0], [0, gain]); endfunction
--- a/scripts/control/system/packedform.m +++ b/scripts/control/system/packedform.m @@ -87,9 +87,9 @@ disp("Object oriented programming:") disp("It is recommended that users do not directly access the internal") disp("variables themselves, but use the interface functions") -disp(" fir2sys ss2sys tf2sys sys2fir") +disp(" fir ss tf sys2fir") disp(" sys2ss sys2tf sys2zp syschtsam") disp(" sysdimensions sysgetsignals syssetsignals sysgettype") -disp(" zp2sys") +disp(" zp ") disp("to create/access internal variables. "); page_screen_output = save_var;
--- a/scripts/control/system/parallel.m +++ b/scripts/control/system/parallel.m @@ -60,7 +60,7 @@ Bsys = syssetsignals(Bsys,"in",__sysdefioname__(length(Ain),"Bin_u")); sysp = sysgroup(Asys,Bsys); - sysD = ss2sys([],[],[],[eye(mA);eye(mA)]); + sysD = ss([],[],[],[eye(mA);eye(mA)]); sysp = sysmult(sysp,sysD); sysp = syssetsignals(sysp,"in",Ain);
--- a/scripts/control/system/ss2sys.m +++ b/scripts/control/system/ss2sys.m @@ -17,7 +17,7 @@ ## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. ## -*- texinfo -*- -## @deftypefn {Function File} {} ss2sys (@var{a}, @var{b}, @var{c}, @var{d}, @var{tsam}, @var{n}, @var{nz}, @var{stname}, @var{inname}, @var{outname}, @var{outlist}) +## @deftypefn {Function File} {} ss (@var{a}, @var{b}, @var{c}, @var{d}, @var{tsam}, @var{n}, @var{nz}, @var{stname}, @var{inname}, @var{outname}, @var{outlist}) ## Create system structure from state-space data. May be continous, ## discrete, or mixed (sampeled-data) ## @@ -140,7 +140,7 @@ ## octave:1> a = [1 2 3; 4 5 6; 7 8 10]; ## octave:2> b = [0 0 ; 0 1 ; 1 0]; ## octave:3> c = eye(3); -## octave:4> sys = ss2sys(a,b,c,[],0,3,0,list("volts","amps","joules")); +## octave:4> sys = ss(a,b,c,[],0,3,0,list("volts","amps","joules")); ## octave:5> sysout(sys); ## Input(s) ## 1: u_1 @@ -183,105 +183,9 @@ ## Author: John Ingram <ingraje@eng.auburn.edu> ## Created: July 20, 1996 -function retsys = ss2sys (a, b, c, d, tsam, n, nz, stname, inname, outname, outlist) - - ## Test for correct number of inputs - if ((nargin < 3) | (nargin > 11)) - usage("retsys = ss2sys (a,b,c{,d,tsam,n,nz,stname,inname,outname,outlist})"); - endif - - ## verify A, B, C, D arguments - ## If D is not specified, set it to a zero matrix of appriate dimension. - if (nargin == 3) d = zeros(rows(c) , columns(b)); - elseif (isempty(d)) d = zeros(rows(c) , columns(b)); endif - - ## Check the dimensions - [na,m,p] = abcddim(a,b,c,d); - - ## If dimensions are wrong, exit function - if (m == -1) - error("a(%dx%d), b(%dx%d), c(%dx%d), d(%dx%d); incompatible", ... - rows(a), columns(a), rows(b), columns(b), rows(c), columns(c), ... - rows(d), columns(d)); - endif - - ## check for tsam input - if(nargin < 5) tsam = 0; - elseif( !( is_sample(tsam) | (tsam == 0) ) ) - error("tsam must be a nonnegative real scalar"); - endif - - ## check for continuous states - if( (nargin < 6) & (tsam == 0) ) n = na; - elseif(nargin < 6) n = 0; - elseif((!ismatrix(n)) | isstr(n)) - error("Parameter n is not a numerical value."); - elseif( (!isscalar(n)) | (n < 0 ) | (n != round(n)) ) - if(isscalar(n)) error("invalid value of n=%d,%e",n,n); - else error("invalid value of n=(%dx%d)", ... - rows(n), columns(n)); endif - endif - - ## check for num discrete states - if( (nargin < 7) & (tsam == 0)) nz = 0; - elseif(nargin < 7) nz = na - n; - elseif((!ismatrix(nz)) | isstr(nz)) - error("Parameter nz is not a numerical value."); - elseif( (!isscalar(nz)) | (nz < 0 ) | (nz != round(nz)) ) - if(isscalar(nz)) - error(["invalid value of nz=",num2str(nz)]); - else - error(["invalid value of nz=(",num2str(rows(nz)),"x", ... - num2str(columns(nz)),")"]); - endif - endif - - ## check for total number of states - if( (n + nz) != na ) - error(["invalid: a is ",num2str(na),"x",num2str(na),", n=", ... - num2str(n),", nz=",num2str(nz)]); - endif - - ## construct system with default names - retsys.a = a; - retsys.b = b; - retsys.c = c; - retsys.d = d; - - retsys.n = n; - retsys.nz = nz; - retsys.tsam = tsam; - retsys.yd = zeros(1,p); # default value entered below - - ## Set the system vector: active = 2(ss), updated = [0 0 1]; - retsys.sys = [2, 0, 0, 1]; - - retsys.stname = __sysdefstname__ (n, nz); - retsys.inname = __sysdefioname__ (m, "u"); - retsys.outname = __sysdefioname__ (p, "y"); - - ## check for state names - if(nargin >= 8) - if(!isempty(stname)) retsys = syssetsignals(retsys,"st",stname); endif - endif - - ## check for input names - if(nargin >= 9) - if(!isempty(inname)) retsys = syssetsignals(retsys,"in",inname); endif - endif - - ## check for output names - if(nargin >= 10) - if(!isempty(outname)) retsys = syssetsignals(retsys,"out",outname); endif - endif - - ## set up yd - if(nargin < 11) - retsys = syssetsignals(retsys,"yd",ones(1,p)*(tsam > 0)); - else - if(!isempty(outlist)) - retsys = syssetsignals(retsys,"yd",ones(size(outlist)),outlist); - endif - endif +function retsys = ss2sys (varargin ) + + warning("ss2sys is deprecated. Use ss() instead."); + retsys = ss(varargin{:}); endfunction
--- a/scripts/control/system/sys2tf.m +++ b/scripts/control/system/sys2tf.m @@ -20,11 +20,11 @@ ## @deftypefn {Function File} {[@var{num}, @var{den}, @var{tsam}, @var{inname}, @var{outname}] =} sys2tf (@var{sys}) ## Extract transfer function data from a system data structure ## -## See tf2sys for parameter descriptions. +## See tf for parameter descriptions. ## ## @strong{Example} ## @example -## octave:1> sys=ss2sys([1 -2; -1.1,-2.1],[0;1],[1 1]); +## octave:1> sys=ss([1 -2; -1.1,-2.1],[0;1],[1 1]); ## octave:2> [num,den] = sys2tf(sys) ## num = 1.0000 -3.0000 ## den = 1.0000 1.1000 -4.3000 @@ -43,7 +43,7 @@ endif if( !isstruct(Asys)) - error("Asys must be a system data structure (see ss2sys, tf2sys, zp2sys)"); + error("Asys must be a system data structure (see ss, tf, zp)"); elseif (! is_siso(Asys) ) [n, nz, m, p] = sysdimensions(Asys); error(["system is not SISO (",num2str(m)," inputs, ...
--- a/scripts/control/system/sys2zp.m +++ b/scripts/control/system/sys2zp.m @@ -21,11 +21,11 @@ ## Extract zero/pole/leading coefficient information from a system data ## structure ## -## See zp2sys for parameter descriptions. +## See zp for parameter descriptions. ## ## @strong{Example} ## @example -## octave:1> sys=ss2sys([1 -2; -1.1,-2.1],[0;1],[1 1]); +## octave:1> sys=ss([1 -2; -1.1,-2.1],[0;1],[1 1]); ## octave:2> [zer,pol,k] = sys2zp(sys) ## zer = 3.0000 ## pol =
--- a/scripts/control/system/sysadd.m +++ b/scripts/control/system/sysadd.m @@ -50,18 +50,18 @@ endif ## collect all arguments - arglist = list(); + arglist = {}; for kk=1:nargin - arglist(kk) = varargin{kk}; - if(!isstruct(nth(arglist,kk))) + arglist{kk} = varargin{kk}; + if(!isstruct(arglist{kk})) error("sysadd: argument %d is not a data structure",kk); endif endfor ## check system dimensions - [n,nz,mg,pg,Gyd] = sysdimensions(nth(arglist,1)); + [n,nz,mg,pg,Gyd] = sysdimensions(arglist{1}); for kk=2:nargin - [n,nz,mh,ph,Hyd] = sysdimensions(nth(arglist,kk)); + [n,nz,mh,ph,Hyd] = sysdimensions(arglist{kk}); if(mg != mh) error("arg 1 has %d inputs; arg %d has vs %d inputs",mg,kk,mh); elseif(pg != ph) @@ -74,29 +74,32 @@ ## perform the add if (nargin == 2) - Gsys = nth(arglist,1); - Hsys = nth(arglist,2); + Gsys = arglist{1}; + Hsys = arglist{2}; - if (! strcmp (sysgettype (Gsys), "tf")) + # check if adding scalar transfer functions with identical denoms + [Gn, Gnz, Gm, Gp] = sysdimensions(Gsys); + [Hn, Hnz, Hm, Hp] = sysdimensions(Hsys); + if ( Gm ==1 & Gp == 1 & Hm == 1 & Hp == 1 & Gn == Hn & Gnz == Hnz ) + # dimensions are compatible, check if can add [Gnum,Gden,GT,Gin,Gout] = sys2tf(Gsys); - endif - - if (! strcmp (sysgettype (Hsys),"tf")) [Hnum,Hden,HT,Hin,Hout] = sys2tf(Hsys); - endif + if (length(Hden) == length(Gden) ) + if( (Hden == Gden) & (HT == GT) ) + sys = tf(Gnum+Hnum,Gden,GT,Gin,Gout); - ## see if adding transfer functions with identical denominators - if (length(Hden) == length(Gden) ) - if( (Hden == Gden) & (HT == GT) ) - sys = tf2sys(Gnum+Hnum,Gden,GT,Gin,Gout); - return + return; # return prematurely since the add is done. + endif endif - ## if not, we go on and do the usual thing... endif ## make sure in ss form Gsys = sysupdate(Gsys,"ss"); Hsys = sysupdate(Hsys,"ss"); + Gin = sysgetsignals(Gsys,"in"); + Gout = sysgetsignals(Gsys,"out"); + Hin = sysgetsignals(Hsys,"in"); + Hout = sysgetsignals(Hsys,"out"); ## change signal names to avoid warning messages from sysgroup Gsys = syssetsignals(Gsys,"in",__sysdefioname__(length(Gin),"Gin_u")); @@ -113,9 +116,9 @@ else ## multiple systems (or a single system); combine together one by one - sys = nth(arglist,1); + sys = arglist{1}; for kk=2:length(arglist) - sys = sysadd(sys,nth(arglist,kk)); + sys = sysadd(sys,arglist{kk}); endfor endif
--- a/scripts/control/system/sysappend.m +++ b/scripts/control/system/sysappend.m @@ -115,8 +115,12 @@ else inname = __sysdefioname__(Bm,"u",(Am+1)); endif - if(Am) Ain = append(Ain,inname); - else Ain = inname; endif + + if(Am) + Ain = __sysconcat__(Ain,inname); + else + Ain = inname; + endif ## default b matrix if(isempty(b)) b = zeros(Ann+Anz,(Bm-Am)); @@ -144,7 +148,7 @@ else outname = __sysdefioname__(Bp,"y",(Ap+1)); endif - if(Ap) Aout = append(Aout,outname); + if(Ap) Aout = __sysconcat__(Aout,outname); else Aout = outname; endif ## construct new yd entries @@ -183,7 +187,7 @@ Ad = d; ## construct return system - retsys = ss2sys(Aa,Ab,Ac,Ad,Ats,Ann,Anz,Ast,Ain,Aout,find(Ayd == 1)); + retsys = ss(Aa,Ab,Ac,Ad,Ats,Ann,Anz,Ast,Ain,Aout,find(Ayd == 1)); unwind_protect_cleanup warn_empty_list_elements = save_warn_empty_list_elements;
--- a/scripts/control/system/sysconnect.m +++ b/scripts/control/system/sysconnect.m @@ -267,12 +267,13 @@ ## rebuild system Ts = sysgettsam(sys); [stnam,innam,outnam] = sysgetsignals(sys); - sys = ss2sys(Ac,Bc,Cc,Dc,Ts,nc,nz,stnam,innam,outnam,find(yd)); + sys = ss(Ac,Bc,Cc,Dc,Ts,nc,nz,stnam,innam,outnam,find(yd)); ## update connected input names for ii = 1:length(input_list) idx = input_list(ii); - strval = sprintf("%s*",nth(sysgetsignals(sys,"in",idx),1) ); + tmpval = sysgetsignals(sys,"in",idx); + strval = sprintf("%s*",tmpval{1} ); sys = syssetsignals(sys,"in",strval,idx); endfor
--- a/scripts/control/system/syscont.m +++ b/scripts/control/system/syscont.m @@ -82,7 +82,7 @@ Ccd = sys_c(y_c,st_d); inname = sys_inname; - csys = ss2sys(Acc,Bcc,Ccc,Dcc,0,sys_n,0,stname,inname,outname); + csys = ss(Acc,Bcc,Ccc,Dcc,0,sys_n,0,stname,inname,outname); unwind_protect_cleanup warn_empty_list_elements = save_warn_empty_list_elements;
--- a/scripts/control/system/sysdimensions.m +++ b/scripts/control/system/sysdimensions.m @@ -80,13 +80,13 @@ m = length(sysgetsignals(sys,"in")); p = length(sysgetsignals(sys,"out")); yd = sys.yd; - valid_options = list("all","cst","dst","st","in","out"); - valid_values = list(n,n,nz,n+nz,m,p); + valid_options = {"all","cst","dst","st","in","out"}; + valid_values = {n,n,nz,n+nz,m,p}; valid_opt = 0; for ii=1:length(valid_options) - if(strcmp(nth(valid_options,ii),opt)) - n = nth(valid_values,ii); + if(strcmp(valid_options{ii},opt)) + n = valid_values{ii}; valid_opt = 1; if(ii > 1 & nargout > 1) warning("opt=%s, %d output arguments requested",opt,nargout);
--- a/scripts/control/system/sysdisc.m +++ b/scripts/control/system/sysdisc.m @@ -89,7 +89,7 @@ if(!isempty(outname)) tsam = sysgettsam(sys); [nc,nz] = sysdimensions(sys); - dsys = ss2sys(Add,Bdd,Cdd,Ddd,tsam,0,nz,stname,inname,outname,outlist); + dsys = ss(Add,Bdd,Cdd,Ddd,tsam,0,nz,stname,inname,outname,outlist); else dsys=[]; endif
--- a/scripts/control/system/sysdup.m +++ b/scripts/control/system/sysdup.m @@ -62,7 +62,7 @@ endif if( !isstruct(Asys)) - error("Asys must be a system data structure (see ss2sys, tf2sys, or zp2sys)") + error("Asys must be a system data structure (see ss, tf, or zp)") endif Asys = sysupdate(Asys,"ss"); @@ -103,7 +103,7 @@ tsam = sysgettsam(Asys); ## pack system and then rename signals - retsys = ss2sys(aa,bb,cc,dd,tsam,nn,nz); + retsys = ss(aa,bb,cc,dd,tsam,nn,nz); retsys = syssetsignals(retsys,"in",innam,1:mm); retsys = syssetsignals(retsys,"out",outnam,1:pp); retsys = syssetsignals(retsys,"yd",yd,1:pp);
--- a/scripts/control/system/sysgetsignals.m +++ b/scripts/control/system/sysgetsignals.m @@ -44,10 +44,10 @@ ## index(indices) or name(s) or signals; see @code{sysidx} ## ## @item strflg -## flag to return a string instead of a list; Values: +## flag to return a string instead of a cell array; Values: ## @table @code ## @item 0 -## (default) return a list (even if signum specifies an individual signal) +## (default) return a cell array (even if signum specifies an individual signal) ## ## @item 1 ## return a string. Exits with an error if signum does not specify an @@ -63,7 +63,7 @@ ## @item stname ## @itemx inname ## @itemx outname -## signal names (lists of strings); names of states, +## signal names (cell array of strings); names of states, ## inputs, and outputs, respectively ## @item yd ## binary vector; @var{yd}(@var{ii}) is nonzero if output @var{ii} is @@ -73,13 +73,13 @@ ## @item If @var{sigid} is specified but @var{signum} is not specified, then ## @table @code ## @item sigid="in" -## @var{siglist} is set to the list of input names +## @var{siglist} is set to the cell array of input names ## ## @item sigid="out" -## @var{siglist} is set to the list of output names +## @var{siglist} is set to the cell array of output names ## ## @item sigid="st" -## @var{siglist} is set to the list of state names +## @var{siglist} is set to the cell array of state names ## ## stage signals ## @item sigid="yd" @@ -90,7 +90,7 @@ ## @end table ## ## @item if the first three input arguments are specified, then @var{signame} is -## a list of the specified signal names (@var{sigid} is @code{"in"}, +## a cell array of the specified signal names (@var{sigid} is @code{"in"}, ## @code{"out"}, or @code{"st"}), or else the logical flag ## indicating whether output(s) @var{signum} is(are) discrete (@var{sigval}=1) ## or continuous (@var{sigval}=0). @@ -98,7 +98,7 @@ ## ## @strong{Examples} (From @code{sysrepdemo}) ## @example -## octave> sys=ss2sys(rand(4),rand(4,2),rand(3,4)); +## octave> sys=ss(rand(4),rand(4,2),rand(3,4)); ## octave> [Ast,Ain,Aout,Ayd] = sysgetsignals(sys) i # get all signal names ## Ast = ## ( @@ -127,7 +127,7 @@ ## [1] = u_1 ## [2] = u_2 ## ) -## octave> Aout = sysgetsignals(sys,"out",2) # get name of output 2 (in list) +## octave> Aout = sysgetsignals(sys,"out",2) # get name of output 2 (in cell array) ## Aout = ## ( ## [1] = y_2 @@ -139,7 +139,7 @@ function [stname, inname, outname, yd] = sysgetsignals (sys, sigid, signum, strflg) - ## Adapted from ss2sys + ## Adapted from ss if(nargin < 1 | nargin > 4 | nargout > 4) usage("[stname{,inname,outname,yd}] = sysgetsignals(sys{,sigid,signum})") @@ -168,7 +168,7 @@ endif if(nargin >= 3) if( is_signal_list(signum) | isstr(signum) ) - signum = listidx(stname,signum); + signum = cellidx(stname,signum); end if(max(signum) > length(stname)) error(sprintf("sysgetsignals(sys,\"%s\",%d):only %d entries.\n", ... @@ -184,7 +184,7 @@ if(length(signum) > 1) error("strflg=1, length(signum) = %d",length(signum)); endif - stname = nth(stname,signum); + stname = stname{signum}; otherwise, error ("invalid value of strflg = %e", strflg); endswitch
--- a/scripts/control/system/sysgettype.m +++ b/scripts/control/system/sysgettype.m @@ -37,7 +37,7 @@ error ("sysgettype: input sys is not a structure"); endif - typestr = list ("tf", "zp", "ss"); - systype = nth (typestr, sys.sys(1) + 1); + typestr = {"tf", "zp", "ss"}; + systype = typestr{ sys.sys(1) + 1}; endfunction
--- a/scripts/control/system/sysgroup.m +++ b/scripts/control/system/sysgroup.m @@ -61,18 +61,18 @@ endif ## collect all arguments - arglist = list(); + arglist = {}; for kk=1:nargin arglist(kk) = varargin{kk}; - if(!isstruct(nth(arglist,kk))) + if(!isstruct(arglist{kk})) error("sysgroup: argument %d is not a data structure",kk); endif endfor if(nargin == 2) ## the usual case; group the two systems together - Asys = nth(arglist,1); - Bsys = nth(arglist,2); + Asys = arglist{1}; + Bsys = arglist{2}; ## extract information from Asys, Bsys to consruct sys Asys = sysupdate(Asys,"ss"); @@ -94,10 +94,54 @@ error("sysgroup: Asys.tsam=%e, Bsys.tsam =%e", Atsam, Btsam); endif - A = [Aa,zeros(nA,nB); zeros(nB,nA),Ba]; - B = [Ab,zeros(nA,m2); zeros(nB,m1),Bb]; - C = [Ac,zeros(p1,nB); zeros(p2,nA),Bc]; - D = [Ad,zeros(p1,m2); zeros(p2,m1),Bd]; + if(nA*nB > 0) + A12 = zeros(nA,nB); + else + A12 = []; + endif + A = [Aa,A12; A12', Ba]; + + if(nA*m2 > 0) + B12 = zeros(nA,m2); + else + B12 = []; + endif + if(nB*m1 > 0) + B21 = zeros(nB,m1); + else + B21 = []; + endif + if(isempty(Ab)) + Ab = []; + endif + if(isempty(Bb)) + Bb = []; + endif + B = [Ab, B12; B21, Bb]; + + if(p1*nB > 0) + C12 = zeros(p1,nB); + else + C12 = []; + endif + if(p2*nA > 0) + C21 = zeros(p2,nA); + else + C21 = []; + endif + C = [Ac, C12; C21,Bc]; + + if(p1*m2 > 0) + D12 = zeros(p1,m2); + else + D12 = []; + endif + if(p2*m1 > 0) + D21 = zeros(p2,m1); + else + D21 = []; + endif + D = [Ad, D12; D21, Bd]; tsam = max(Atsam,Btsam); ## construct combined signal names; stnames must check for pure gain blocks @@ -106,10 +150,10 @@ elseif(isempty(Bst)) stname = Ast; else - stname = append(Ast, Bst); + stname= __sysconcat__(Ast,Bst); endif - inname = append(Ain, Bin); - outname = append(Aout,Bout); + inname = __sysconcat__(Ain,Bin); + outname = __sysconcat__(Aout,Bout); ## Sort states into continous first, then discrete dstates = ones(1,(nA+nB)); @@ -134,14 +178,14 @@ outlist = find([Ayd, Byd]); ## build new system - sys = ss2sys(A,B,C,D,tsam,An+Bn,Anz+Bnz,stname,inname,outname); + sys = ss(A,B,C,D,tsam,An+Bn,Anz+Bnz,stname,inname,outname); else ## multiple systems (or a single system); combine together one by one - sys = nth(arglist,1); + sys = arglist{1}; for kk=2:length(arglist) printf("sysgroup: kk=%d\n",kk); - sys = sysgroup(sys,nth(arglist,kk)); + sys = sysgroup(sys,arglist{kk}); endfor endif
--- a/scripts/control/system/sysmin.m +++ b/scripts/control/system/sysmin.m @@ -64,9 +64,9 @@ cstnam = stnam(crng); dstnam = stnam(drng); - cinnam = append(innam,stnam(drng)); - coutnam = append(outnam,stnam(drng)); - csys = ss2sys(Ac,[Bc,Acd],[Cc;Adc]); + cinnam = __sysconcat__(innam,stnam(drng)); + coutnam = __sysconcat__(outnam,stnam(drng)); + csys = ss(Ac,[Bc,Acd],[Cc;Adc]); csys = syssetsignals(csys,"st",cstnam); csys = syssetsignals(csys,"in",cinnam); csys = syssetsignals(csys,"out",coutnam); @@ -90,9 +90,9 @@ Adc = ccc(p + (1:nz),:); # recombine to reduce discrete part of the system - dinnam = append(innam,cstnam); - doutnam = append(outnam,cstnam); - dsys = ss2sys(Ad,[Bd,Adc],[Cd;Acd],[],tsam); + dinnam = __sysconcat__(innam,cstnam); + doutnam = __sysconcat__(outnam,cstnam); + dsys = ss(Ad,[Bd,Adc],[Cd;Acd],[],tsam); dsys = syssetsignals(dsys,"st",dstnam); dsys = syssetsignals(dsys,"in",dinnam); dsys = syssetsignals(dsys,"out",doutnam); @@ -111,11 +111,11 @@ Adc = dbb(:,m+(1:cn)); Cd = dcc(1:p,:); Acd = dcc(p+(1:cn),:); - stnam = append(cstnam,dstnam); + stnam = __sysconcat__(cstnam,dstnam); aa = [Ac, Acd; Adc, Ad]; bb = [Bc; Bd]; cc = [Cc, Cd]; - retsys = ss2sys([Ac, Acd; Adc, Ad], [Bc ; Bd], [Cc, Cd], dd, tsam, ... + retsys = ss([Ac, Acd; Adc, Ad], [Bc ; Bd], [Cc, Cd], dd, tsam, ... cn, nz, stnam, innam, outnam, find(yd == 1)); end endif @@ -158,7 +158,7 @@ endswitch innam = sysgetsignals(sys,"in"); outnam= sysgetsignals(sys,"out"); - retsys = ss2sys(aa,bb,cc,dd,Ts,nn,nz,[],innam,outnam); + retsys = ss(aa,bb,cc,dd,Ts,nn,nz,[],innam,outnam); case(1), ## reduced model with physical states [cflg,Uc] = is_controllable(sys); xc = find(max(abs(Uc')) != 0);
--- a/scripts/control/system/sysmult.m +++ b/scripts/control/system/sysmult.m @@ -43,27 +43,28 @@ endif ## collect all arguments - arglist = list(); + arglist = {}; for kk=1:nargin - arglist(kk) = varargin{kk}; - if(!isstruct(nth(arglist,kk))) + arglist{kk} = varargin{kk}; + if(!isstruct(arglist{kk})) error("sysadd: argument %d is not a data structure",kk); endif endfor ## check system dimensions - [n,nz,mg,pg,Gyd] = sysdimensions(nth(arglist,1)); + [n,nz,mg,pg,Gyd] = sysdimensions(arglist{1}); for kk=2:nargin - [n,nz,mh,ph,Hyd] = sysdimensions(nth(arglist,kk)); + [n,nz,mh,ph,Hyd] = sysdimensions(arglist{kk}); if(ph != mg) error("arg %d has %d outputs; arg %d has %d inputs",kk,ph,kk-1,mg); endif - [n,nz,mg,pg,Gyd] = sysdimensions(nth(arglist,kk)); # for next iteration + [n,nz,mg,pg,Gyd] = sysdimensions(arglist{kk}); # for next iteration endfor ## perform the multiply if(nargin == 2) - Asys = nth(arglist,1); Bsys = nth(arglist,2); + Asys = arglist{1}; + Bsys = arglist{2}; [An,Anz,Am,Ap] = sysdimensions(Asys); [Bn,Bnz,Bm,Bp] = sysdimensions(Bsys); @@ -103,9 +104,9 @@ else ## multiple systems (or a single system); combine together one by one - sys = nth(arglist,1); + sys = arglist{1}; for kk=2:length(arglist) - sys = sysmult(sys,nth(arglist,kk)); + sys = sysmult(sys,arglist{kk}); endfor endif
--- a/scripts/control/system/sysprune.m +++ b/scripts/control/system/sysprune.m @@ -118,7 +118,7 @@ lst = length(state_idx); if( !isstruct(sys)) - error("Asys must be a system data structure (see ss2sys, tf2sys, or zp2sys)") + error("Asys must be a system data structure (see ss, tf, or zp)") elseif(pp < lo) error([num2str(lo)," output_idx entries, system has only ", ... num2str(pp)," outputs"]); @@ -147,7 +147,7 @@ max_c,state_idx(max_c)); warning("sysprune: sys has %d continuous states, %d discrete states", ... nn,nz); - error("continuous/discrete state partition not preserved ; see ss2sys"); + error("continuous/discrete state partition not preserved ; see ss"); endif endif @@ -168,5 +168,5 @@ stnam = stnam(state_idx); nn1 = length(find(state_idx <= nn)); nz1 = length(find(state_idx > nn)); - sys = ss2sys(aa,bb,cc,dd,tsam,nn1,nz1,stnam,innam,outnam,find(yd)); + sys = ss(aa,bb,cc,dd,tsam,nn1,nz1,stnam,innam,outnam,find(yd)); endfunction
--- a/scripts/control/system/sysrepdemo.m +++ b/scripts/control/system/sysrepdemo.m @@ -45,7 +45,7 @@ disp(" ") syschoice = menu("Octave System Representation Menu", ... "General overview of system representation (DO THIS FIRST)", ... - "Initialize a system (ss2sys, tf2sys, zp2sys)", ... + "Initialize a system (ss, tf, zp)", ... "Extract data from a system(sys2ss, sys2tf, sys2zp, etc.)", ... "Update internal representation (sysupdate)", ... "View the internal contents of a system (sysout)", ... @@ -79,10 +79,10 @@ disp(["menu option ",num2str(ch_details)]); disp("The data structure used in the OCST is called a \"system data structure.\""); disp("A system data structure is contstructed with one of:") - disp(" fir2sys (FIR transfer function to system)") - disp(" ss2sys (state space matrices to system)") - disp(" tf2sys (SISO transfer function to system)") - disp(" zp2sys (SISO zero/pole/leading coefficient to system)") + disp(" fir (FIR transfer function to system)") + disp(" ss (state space matrices to system)") + disp(" tf (SISO transfer function to system)") + disp(" zp (SISO zero/pole/leading coefficient to system)") disp(" ") disp(["These functions are discussed in in menu option ",num2str(ch_init)]) disp("The data in a system may be extracted using ") @@ -106,9 +106,9 @@ while(formopt != 4) disp("Three data formats may be used to initialize a system:") formopt = menu("System data structure initialization menu", ... - "State space form (ss2sys)", ... - "Transfer function form (tf2sys)", ... - "zero-pole form (zp2sys)", ... + "State space form (ss)", ... + "Transfer function form (tf)", ... + "zero-pole form (zp)", ... "Return to System representation menu"); if(formopt == 1) disp("State space representation of a system is based on the usual") @@ -127,7 +127,7 @@ "Double integrator example", ... "Double delay (discrete-time) example", ... "Summing junction (D-matrix only) example", ... - "ss2sys details (help ss2sys)", ... + "ss details (help ss)", ... "return to system initialization menu", ... "return to system representation main menu"); if(ssopt == 1) @@ -139,7 +139,7 @@ run_cmd cmd = "c = [1, 0];"; run_cmd - cmd = "sys = ss2sys(a,b,c);"; + cmd = "sys = ss(a,b,c);"; run_cmd disp("The state space form of the system is seen via sysout:") cmd = "sysout(sys)"; @@ -162,7 +162,7 @@ run_cmd cmd = "c = [1, 0];"; run_cmd - cmd = "sys=ss2sys(a,b,c,[],1e-3);"; + cmd = "sys=ss(a,b,c,[],1e-3);"; run_cmd cmd = "sysout(sys)"; run_cmd @@ -199,29 +199,29 @@ disp("First, we set the matrix D:") cmd = "D = [1, -1];"; run_cmd - disp("ss2sys allows the initialization of signal and state names") + disp("ss allows the initialization of signal and state names") disp("(see option 4), so we initialize these as follows:") - cmd = "inname = list(\"r(t)\",\"y(t)\");"; + cmd = "inname = {\"r(t)\",\"y(t)\"};"; run_cmd; cmd = "outname = \"e(t)\";"; run_cmd disp("Since the system is continous time and without states,") - disp("the ss2sys inputs tsam, n, and nz are all zero:") - cmd = "sys = ss2sys([],[],[],D,0,0,0,[],inname,outname);"; + disp("the ss inputs tsam, n, and nz are all zero:") + cmd = "sys = ss([],[],[],D,0,0,0,[],inname,outname);"; run_cmd disp("The resulting system is:") cmd = "sysout(sys)"; run_cmd disp("A discrete-time summing block can be implemented by setting") disp("the sampling time positive:") - cmd = "sys = ss2sys([],[],[],D,1e-3,0,0,[],inname,outname);"; + cmd = "sys = ss([],[],[],D,1e-3,0,0,[],inname,outname);"; run_cmd disp("The resulting system is:") cmd = "sysout(sys)"; run_cmd prompt elseif(ssopt == 4) - help ss2sys + help ss disp(" ") disp(" ") disp("Notice that state-space form allows a single system to have") @@ -241,7 +241,7 @@ "Continuous time initialization" , ... "Discrete time initialization" , ... "User specified signal names" , ... - "tf2sys details (help tf2sys)", ... + "tf details (help tf)", ... "Return to system initialization menu", ... "Return to system representation main menu"); if(tfopt == 1) # continuous time @@ -259,10 +259,10 @@ run_cmd cmd = "denom = [1, -2, 6]"; run_cmd - cmd = "sys = tf2sys(num,denom);"; + cmd = "sys = tf(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 = tf([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") @@ -279,7 +279,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=tf([5, -1], [1, 2, -6], 1e-3);"; run_cmd cmd = "sysout(sys)"; run_cmd @@ -294,7 +294,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=tf(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).") @@ -306,7 +306,7 @@ disp("signal names in plots.)") prompt elseif(tfopt == 4) # help - help tf2sys + help tf prompt elseif(tfopt == 6) # return to main menu formopt = 4; @@ -319,7 +319,7 @@ "Continuous time initialization" , ... "Discrete time initialization" , ... "User specified signal names" , ... - "zp2sys details (help zp2sys)", ... + "zp details (help zp)", ... "Return to system initialization menu", ... "Return to system representation main menu"); if(zpopt == 1) # continuous time @@ -340,10 +340,10 @@ run_cmd cmd = "k = 5"; run_cmd - cmd = "sys = zp2sys(num,denom,k);"; + cmd = "sys = zp(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 = zp([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") @@ -360,7 +360,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=zp([5, -1],[1, 2, -6],5,1e-3);"; run_cmd cmd = "sysout(sys)"; run_cmd @@ -375,7 +375,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=zp([],[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).") @@ -387,7 +387,7 @@ disp("signal names in plots.)") prompt elseif(zpopt == 4) # help - help zp2sys + help zp prompt elseif(zpopt == 6) # return to main menu formopt = 4; @@ -397,7 +397,7 @@ endwhile elseif(syschoice == ch_extract) # extract system information disp("Extract information from a system data structure in a selected format:") - disp("The actions of operations ss2sys, tf2sys, and zp2sys are reversed by") + disp("The actions of operations ss, tf, and zp are reversed by") disp("respective functions sys2ss, sys2tf, and sys2zp. The latter two"); disp("functions are applicable only to SISO systems.") formopt = 0; @@ -419,7 +419,7 @@ help sys2zp elseif(formopt == 4) help sysgetsignals - cmd="sys=ss2sys(rand(4),rand(4,2),rand(3,4));"; + cmd="sys=ss(rand(4),rand(4,2),rand(3,4));"; run_cmd printf("Example: All signals names can be extracted by\n"); cmd = "[Ast,Ain,Aout,Ayd] = sysgetsignals(sys)"; @@ -430,7 +430,7 @@ printf("Example: The name of output signal 2 can be extracted as\n"); cmd = "Aout = sysgetsignals(sys,\"out\",2)"; run_cmd - printf("\nNotice that Aout is returned as a list; the signal name\n"); + printf("\nNotice that Aout is returned as a cell array; the signal name\n"); printf("itself is obtained by specifying the input parameter strflg\n"); cmd = "Aout = sysgetsignals(sys,\"out\",2,1)"; run_cmd @@ -454,7 +454,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=zp([1, 2],[3, 4, 5],6)"; run_cmd disp(" ") disp("Notice the internal variables in the structure include zer, pol, and k,") @@ -472,7 +472,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=zp(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
--- a/scripts/control/system/sysscale.m +++ b/scripts/control/system/sysscale.m @@ -92,12 +92,12 @@ if strcmp(sysgettype(sys),"tf") [num,den,tsam,innam,outnam] = sys2tf(sys); num = num*inscale*outscale; - sys = tf2sys(num,den,tsam,innam,outnam,find(sysyd)); + sys = tf(num,den,tsam,innam,outnam,find(sysyd)); return elseif strcmp(sysgettype(sys),"zp") [zer,pol,kk,tsam,innam,outnam] = sys2zp(sys); kk = kk*inscale*outscale; - sys = zp2sys(zer,pol,k,tsam,innam,outnam,find(sysyd)); + sys = zp(zer,pol,k,tsam,innam,outnam,find(sysyd)); return endif @@ -133,7 +133,7 @@ inname = sysgetsignals(sys,"in"); endif - sys = ss2sys(sysa,sysb,sysc,sysd,systsam,nn,nz,sysstname, ... + sys = ss(sysa,sysb,sysc,sysd,systsam,nn,nz,sysstname, ... inname,outname,find(sysyd==1)); endfunction
--- a/scripts/control/system/syssetsignals.m +++ b/scripts/control/system/syssetsignals.m @@ -51,7 +51,7 @@ ## indices or names of outputs, yd, inputs, or ## states whose respective names/values should be changed. ## -## Default: replace entire list of names/entire yd vector. +## Default: replace entire cell array of names/entire yd vector. ## @end table ## @strong{Outputs} ## @var{retsys=sys} with appropriate signal names changed @@ -59,7 +59,7 @@ ## ## @strong{Example} ## @example -## octave:1> sys=ss2sys([1 2; 3 4],[5;6],[7 8]); +## octave:1> sys=ss([1 2; 3 4],[5;6],[7 8]); ## octave:2> sys = syssetsignals(sys,"st",str2mat("Posx","Velx")); ## octave:3> sysout(sys) ## Input(s) @@ -121,23 +121,25 @@ sig_vals = sysgetsignals(sys,opt); ## make sure it's in state space form if state names are given - if(strcmp(opt,"st")) sys = sysupdate(sys,"ss"); endif + if(strcmp(opt,"st")) + sys = sysupdate(sys,"ss"); + endif if(strcmp(opt,"yd") == 0) ## it's a signal name list we're changing - if(!islist(names)) - names = list(names); + if(!iscell(names)) + names = {names}; endif - if(!is_signal_list(names)) - if(isstr(nth(names,1))) - warning("syssetsignals(opt=%s): converting string matrix \"names\" to a list of strings",opt); - tmpstr = nth(names,1); + if( (!is_signal_list(names)) & (!isempty(names)) ) + if(isstr(names{1})) + warning("syssetsignals(opt=%s): converting string matrix \"names\" to a cell array of strings",opt); + tmpstr = names{1}; for ii=1:rows(tmpstr) - names(ii) = deblank(tmpstr(ii,:)); + names{ii} = deblank(tmpstr(ii,:)); endfor else names - error("parameter \"names\" must be a list of strings"); + error("parameter \"names\" must be a cell array of strings"); endif endif nsigs = length(sig_vals); @@ -161,7 +163,7 @@ error("opt=%s, sig_idx(%d)=%d, %e: must be an integer between 1 and %d", ... opt, ii, jj, jj, nsigs); endif - sig_vals(jj) = nth(names,ii); + sig_vals{jj} = names{ii}; endfor else
--- a/scripts/control/system/syssub.m +++ b/scripts/control/system/syssub.m @@ -49,18 +49,18 @@ endif ## collect all arguments - arglist = list(); + arglist = {}; for kk=1:nargin - arglist(kk) = varargin{kk}; - if(!isstruct(nth(arglist,kk))) + arglist{kk} = varargin{kk}; + if(!isstruct(arglist{kk})) error("syssub: argument %d is not a data structure",kk); endif endfor ## check system dimensions - [n,nz,mg,pg,Gyd] = sysdimensions(nth(arglist,1)); + [n,nz,mg,pg,Gyd] = sysdimensions(arglist{1}); for kk=2:nargin - [n,nz,mh,ph,Hyd] = sysdimensions(nth(arglist,kk)); + [n,nz,mh,ph,Hyd] = sysdimensions(arglist{kk}); if(mg != mh) error("arg 1 has %d inputs; arg %d has vs %d inputs",mg,kk,mh); elseif(pg != ph) @@ -73,14 +73,15 @@ ## perform the subtract if(nargin == 2) - Gsys = nth(arglist,1); Hsys = nth(arglist,2); + Gsys = arglist{1}; + Hsys = arglist{2}; if( strcmp(sysgettype(Gsys),"tf") | strcmp(sysgettype(Hsys),"tf") ) ## see if subtracting transfer functions with identical denominators [Gnum,Gden,GT,Gin,Gout] = sys2tf(Gsys); [Hnum,Hden,HT,Hin,Hout] = sys2tf(Hsys); if(length(Hden) == length(Gden) ) if( (Hden == Gden) & (HT == GT) ) - sys = tf2sys(Gnum-Hnum,Gden,GT,Gin,Gout); + sys = tf(Gnum-Hnum,Gden,GT,Gin,Gout); return endif ## if not, we go on and do the usual thing... @@ -106,9 +107,9 @@ else ## multiple systems (or a single system); combine together one by one - sys = nth(arglist,1); + sys = arglist{1}; for kk=2:length(arglist) - sys = syssub(sys,nth(arglist,kk)); + sys = syssub(sys,arglist{kk}); endfor endif
--- a/scripts/control/system/sysupdate.m +++ b/scripts/control/system/sysupdate.m @@ -45,7 +45,7 @@ ## Conversion to @code{tf} or @code{zp} exits with an error if the system is ## mixed continuous/digital. ## @end deftypefn -## @seealso{tf2sys, ss2sys, zp2sys, sysout, sys2ss, sys2tf, and sys2zp} +## @seealso{tf, ss, zp, sysout, sys2ss, sys2tf, and sys2zp} ## Author: John Ingram <ingraje@eng.auburn.edu> ## Created: July 9, 1996
--- a/scripts/control/system/tf2sys.m +++ b/scripts/control/system/tf2sys.m @@ -1,4 +1,4 @@ -## Copyright (C) 1996, 1998 Auburn University. All rights reserved. +## Copyright (C) 1996, 1998, 2004 Auburn University. All rights reserved. ## ## This file is part of Octave. ## @@ -29,7 +29,7 @@ ## sampling interval. default: 0 (continuous time) ## @item inname ## @itemx outname -## input/output signal names; may be a string or list with a single string +## input/output signal names; may be a string or cell array with a single string ## entry. ## @end table ## @@ -56,88 +56,11 @@ ## Created: July 29, 1994 ## Name changed to TF2SYS July 1995 ## updated for new system data structure format July 1996 - -function outsys = tf2sys (num, den, tsam, inname, outname) - - ## Test for the correct number of input arguments - if ((nargin < 2) || (nargin > 5)) - usage ("outsys = tf2sys (num, den [, tsam, inname, outname])"); - return - endif - - ## check input format - if( ! ( (isvector(num) || isscalar(num)) && ... - (isvector(den) || isscalar(den))) ) - 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 - num = __tf2sysl__ (num); - den = __tf2sysl__ (den); - - if (length(num) > length(den)) - error("# of poles (%d) < # of zeros (%d)",length(den)-1, length(num)-1); - endif - - ## check sampling interval (if any) - if(nargin <= 2) tsam = 0; # default - elseif (isempty(tsam)) tsam = 0; endif - if ( (! (isscalar(tsam) && (imag(tsam) == 0) )) || (tsam < 0) ) - error("tsam must be a positive real scalar") - endif - - outsys.num = num; - outsys.den = den; - - ## Set the system vector: active = 0(tf), updated = [1 0 0]; - outsys.sys = [0, 1, 0, 0]; +## name changed to tf Feb 2004 - ## Set defaults - outsys.tsam = tsam; - outsys.n = length(den)-1; - outsys.nz = 0; - outsys.yd = 0; # assume discrete-time - ## check discrete time - if(tsam > 0) - [outsys.n,outsys.nz] = swap(outsys.n, outsys.nz); - outsys.yd = 1; - endif - - outsys.inname = __sysdefioname__ (1, "u"); - outsys.outname = __sysdefioname__ (1, "y"); - outsys.stname = __sysdefstname__ (outsys.n, outsys.nz); - - ## Set name of input - if (nargin > 3) - ## make sure its a list of a single string - if(!isempty(inname)) - if(!islist(inname)) inname = list(inname); endif - if( !is_signal_list(inname) ) - error("inname must be a string or list of strings"); - endif - if(length(inname) > 1) - warning("tf2sys: %d input names provided; first used",length(inname)); - inname = inname(1); - endif - outsys = syssetsignals(outsys,"in",inname); - endif - endif - - ## Set name of output - if (nargin > 4) - if(!isempty(outname)) - if(!islist(outname)) outname = list(outname); endif - if(!is_signal_list(outname)) - error("outname must be a string or a list of strings"); - endif - if(length(outname) > 1) - warning("tf2sys: %d output names provided; first used",length(outname)); - outname = outname(1); - endif - outsys = syssetsignals(outsys,"out",outname); - endif - endif +function outsys = tf2sys (varargin) + + warning("tf2sys is deprecated. Use tf() instead."); + outsys = tf(varargin{:}); endfunction
--- a/scripts/control/system/ugain.m +++ b/scripts/control/system/ugain.m @@ -34,6 +34,6 @@ if (nargin != 1 || nargout > 1) usage ("outsys = ugain(n)"); endif - outsys = ss2sys ([], [], [], eye (n)); + outsys = ss ([], [], [], eye (n)); endfunction
--- a/scripts/control/system/zp2ss.m +++ b/scripts/control/system/zp2ss.m @@ -68,7 +68,7 @@ warning("zp2ss: k is complex") endif - zpsys = ss2sys (zeros (0, 0), zeros (0, 1), zeros (1, 0), k); + zpsys = ss (zeros (0, 0), zeros (0, 1), zeros (1, 0), k); ## Find the number of zeros and the number of poles nzer=length(zer); @@ -130,7 +130,7 @@ endswitch ## pack tf into system form and put in series with earlier realization - zpsys1 = tf2sys(num,den,0,"u","yy"); + zpsys1 = tf(num,den,0,"u","yy"); ## change names to avoid warning messages from sysgroup zpsys = syssetsignals (zpsys, "in", "u1", 1);
--- a/scripts/control/system/zp2sys.m +++ b/scripts/control/system/zp2sys.m @@ -55,93 +55,9 @@ ## Modified by John Ingram July 20, 1996 -function outsys = zp2sys (zer, pol, k, tsam, inname, outname) - - ## Test for the correct number of input arguments - if ((nargin < 3) || (nargin > 6)) - usage("outsys = zp2sys(zer,pol,k[,tsam,inname,outname])"); - endif - - ## check input format - if( ! (isvector(zer) | isempty(zer) ) ) - error("zer must be a vector or empty"); - endif - if(!isempty(zer)) - zer = reshape(zer,1,length(zer)); # make it a row vector - endif - - if( ! (isvector(pol) | isempty(pol))) - error("pol must be a vector"); - endif - if(!isempty(pol)) - pol = reshape(pol,1,length(pol)); - endif - - if (! isscalar(k)) - error("k must be a scalar"); - endif - - ## Test proper numbers of poles and zeros. The number of poles must be - ## greater than or equal to the number of zeros. - if (length(zer) > length(pol)) - error(["number of poles (", num2str(length(pol)), ... - ") < number of zeros (", num2str(length(zer)),")"]); - endif - - ## Set the system transfer function - outsys.zer = zer; - outsys.pol = pol; - outsys.k = k; - - ## Set the system vector: active = 1, updated = [0 1 0]; - outsys.sys = [1, 0, 1, 0]; +function outsys = zp2sys ( varargin ) - ## Set defaults - outsys.tsam = 0; - outsys.n = length(pol); - outsys.nz = 0; - outsys.yd = 0; # assume (for now) continuous time outputs - - ## Set the type of system - if (nargin > 3) - if( !isscalar(tsam) ) - error("tsam must be a nonnegative scalar"); - endif - if (tsam < 0) - error("sampling time must be positve") - elseif (tsam > 0) - [outsys.n,outsys.nz] = swap(outsys.n, outsys.nz); - outsys.yd = 1; # discrete-time output - endif - - outsys.tsam = tsam; - endif - - outsys.inname = __sysdefioname__ (1, "u"); - outsys.outname = __sysdefioname__ (1, "y"); - outsys.stname = __sysdefstname__ (outsys.n, outsys.nz); - - ## Set name of input - if (nargin > 4) - ## make sure its a string - if(!isempty(inname)) - if(!islist(inname)) inname = list(inname); endif - if(!is_signal_list(inname)) - error("inname must be a single signal name"); - endif - outsys.inname = inname(1); - endif - endif - - ## Set name of output - if (nargin > 5) - if(!isempty(outname)) - if(!islist(outname)) outname = list(outname); endif - if(!is_signal_list(outname)) - error("outname must be a single signal name"); - endif - outsys.outname = outname(1); - endif - endif + warning("zp2sys is deprecated. Use zp() instead."); + outsys = zp(varargin{:}); endfunction
--- a/scripts/control/util/__outlist__.m +++ b/scripts/control/util/__outlist__.m @@ -55,20 +55,25 @@ endif m = length(name_list); - if(nargin < 4) ilist = 1:m; endif + if(nargin < 4) + ilist = 1:m; + endif if(nargin ==1) tabchar = ""; endif - if(nargin < 3) yd = zeros(1,m); - elseif(isempty(yd)) yd = zeros(1,m); endif + if(nargin < 3) + yd = zeros(1,m); + elseif(isempty(yd)) + yd = zeros(1,m); + endif str_val = ""; - dstr = list(""," (discrete)"); - if((m >= 1) && (islist(name_list))) + dstr = {""," (discrete)"}; + if((m >= 1) && (iscell(name_list))) for ii=1:m str_val = sprintf("%s%s%d: %s%s\n",str_val,tabchar, ilist(ii), ... - nth(name_list,ii),nth(dstr,yd(ii)+1)); + name_list{ii},dstr{yd(ii)+1}); endfor else str_val = sprintf("%sNone",tabchar);
--- a/scripts/control/util/__zgpbal__.m +++ b/scripts/control/util/__zgpbal__.m @@ -104,6 +104,6 @@ endfor endif - retsys = ss2sys(a,b,c,d); + retsys = ss(a,b,c,d); endfunction
--- a/scripts/control/util/strappend.m +++ b/scripts/control/util/strappend.m @@ -31,10 +31,10 @@ error ("suffix must be a single string"); endif - retval = list (); + retval = {}; for ii = 1:length (strlist) - retval(ii) = sprintf ("%s%s", nth (strlist, ii), suffix); + retval{ii} = sprintf ("%s%s", strlist{ii}, suffix); endfor endfunction