home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21eb.zip / octave / SCRIPTS.ZIP / scripts / control / frdemo.m < prev    next >
Text File  |  1999-03-05  |  24KB  |  596 lines

  1. # Copyright (C) 1996,1998 A. Scottedward Hodel 
  2. #
  3. # This file is part of Octave. 
  4. #
  5. # Octave is free software; you can redistribute it and/or modify it 
  6. # under the terms of the GNU General Public License as published by the 
  7. # Free Software Foundation; either version 2, or (at your option) any 
  8. # later version. 
  9. #  
  10. # Octave is distributed in the hope that it will be useful, but WITHOUT 
  11. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
  12. # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
  13. # for more details.
  14. # You should have received a copy of the GNU General Public License 
  15. # along with Octave; see the file COPYING.  If not, write to the Free 
  16. # Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
  17.  
  18. function frdemo()
  19. # Octave Controls toolbox demo: Frequency Response demo
  20. # Written by David Clem August 15, 1994 
  21.  
  22. # a s hodel: updated to match new order of ss2zp outputs
  23. # J Ingram:  updated for system data structure format August 1996
  24.  
  25.   disp("")
  26.   clc
  27.   j = 0;
  28.   while (j != 4)
  29.     disp("");
  30.     j = menu("Octave Controls Systems Toolbox Frequency Response Demo",...
  31.              'Bode analysis (bode)',...
  32.              'Nyquist analysis (nyquist)',...
  33.          "Nichols analysis (nichols)", ...
  34.              'Return to main demo menu');
  35.    
  36.     if (j == 1)
  37.       k1 = 0;
  38.       while (k1 != 4)
  39.         disp("\n");
  40.         clc
  41.  
  42.         k1 = menu("Bode analysis (bode)",...
  43.                   'Continuous system bode analysis',...
  44.                   'Discrete system bode analysis',...
  45.                   'Bode command description', ...
  46.                   'Return to frdemo menu');
  47.        
  48.         if( k1 == 1 )
  49.           disp(" ")
  50.           clc  
  51.           disp("\nContinuous system bode analysis\n");
  52.           disp("Example #1:")
  53.           disp("\nConsider the system sys1=");
  54.           sys1=tf2sys([1 1],[1 0 -1]);
  55.           sysout(sys1);
  56.           disp("\nPole-zero form can be obtained as follows:")
  57.           cmd = "sysout(sys1,""zp"");";
  58.           run_cmd;
  59.           disp("The systems bode plot is obtained as follows:");
  60.           cmd = "bode(sys1);";
  61.           run_cmd;  
  62.           disp("\nNotice that bode automatically labels the plots according to")
  63.           disp("the selected input/output combinations.")
  64.           disp(" ")
  65.           disp("If the frequency range is not specified, bode automatically")
  66.           disp("selects a frequency range based on the natural frequencies of")
  67.           disp("of all poles away from s=0 (or z=1 in discrete time).  Bode")
  68.           disp("then checks to make sure that the phase plot is sufficiently")
  69.           disp("smooth that relevant plot behavior is captured.")
  70.           disp("")
  71.           disp("Bode exits with an error if the system is mixed (both continuous")
  72.           disp("and discrete; see is_digital for conditions)")
  73.           prompt
  74.           disp("\nIf the plot magnitude, phase and frequency data is desired, the");
  75.           disp("user can enter the following command:");
  76.           disp("\n[Mag,Phase,w] = bode(sys);");
  77.           disp("\nThis will return three vectors containing the magnitude,");
  78.           disp("phase and frequency.\n");
  79.           prompt;
  80.  
  81.           disp("")
  82.           clc
  83.           disp("Example #2, sys2=")
  84.           cmd = "sys2=zp2sys([1],[-1 -5],10);";
  85.           eval(cmd);
  86.           cmd = "sysout(sys2);";
  87.           eval(cmd);
  88.           disp("\nThe bode plot command is identical to the tf form:")
  89.           cmd = "bode(sys2);";
  90.           run_cmd;  
  91.           disp("\nThe internal representation of the system is not important;")
  92.           disp("bode automatically sorts it out internally.")
  93.           prompt;
  94.  
  95.           disp("")
  96.           clc
  97.           disp("Example #3, Consider the following state space system sys3=:\n");
  98.           cmd = "sys3=ss2sys([0 1; -1000 -1001], [0;1], [0 -891], 1);";
  99.           eval(cmd);
  100.           cmd = "sysout(sys3);";
  101.           eval(cmd);
  102.           disp("\nOnce again, the bode plot command is the same:");
  103.           cmd = "bode(sys3);";
  104.           run_cmd;
  105.           disp("\nSuppose the user is interested in the response of the system");
  106.           disp("defined over the input frequency range of 1 - 1000 rad/s.\n");
  107.           disp("First, a frequency vector is required.  It can be created");
  108.           disp("with the command:\n");
  109.           cmd = "wrange = logspace(log10(1),log10(1000),100);";
  110.           disp(cmd); 
  111.           eval(cmd);
  112.           disp("\nThis creates a logarithmically scaled frequency vector with");
  113.           disp("100 values between 1 and 1000 rad/s\n");
  114.           disp("Then, the bode command includes wrange in the input arguments");
  115.           disp("like this:");
  116.           cmd = "bode(sys3,wrange);";
  117.           run_cmd;
  118.           prompt; 
  119.  
  120.           disp("")
  121.           clc
  122.             disp("\nExample #4, The state-space system from example 3 will be");
  123.           disp("grouped with the system from example 2 to form a MIMO system");
  124.           disp("The commands to do this grouping are as follows (changing signal");
  125.           disp("names for clarity):");
  126.           cmd = "sys2 = syssetsignals(sys2,\"out\",\"y_sys2\");";
  127.           disp(cmd);  eval(cmd);
  128.           cmd = "sys2 = syssetsignals(sys2,\"in\",\"u_sys2\");";
  129.           disp(cmd);  eval(cmd);
  130.           cmd = "nn = sysdimensions(sys2);";
  131.           disp(cmd);  eval(cmd);
  132.           cmd = "[nn,nz] = sysdimensions(sys2);";
  133.           disp(cmd);  eval(cmd);
  134.           cmd = "sys2 = syssetsignals(sys2,\"st\",sysdefioname(nn+nz,\"x_sys2\"));";
  135.           disp(cmd);  eval(cmd);
  136.           cmd = "sys_mimo = sysgroup(sys2,sys3);";
  137.           disp(cmd); eval(cmd);
  138.           disp("The resulting state-space system (after changing signal names");
  139.           disp("in sys2) is");
  140.           cmd = "sysout(sys_mimo)";
  141.           eval(cmd);
  142.           disp("\nNotice that there are now 2 inputs and 2 outputs, and that it did");
  143.        disp("not matter what form the two systems were in when they were grouped.");
  144.           disp(["\nTo view the system\'s bode plots, execute the",...
  145.             " following command:\n"])
  146.           cmd = "bode(sys_mimo);";
  147.           run_cmd;
  148.           prompt
  149.           disp("\nTo view the bode plots for selected  channels, the command form changes:")
  150.           cmd = "wrange = [];";
  151.           disp(cmd)
  152.           eval(cmd);
  153.           cmd = "out = 1;";
  154.           disp(cmd)
  155.           eval(cmd);
  156.           cmd = "in = 1;";
  157.           disp(cmd)
  158.           eval(cmd);
  159.           cmd = "bode(sys_mimo,wrange,out,in);";
  160.           run_cmd;
  161.           disp("\nNotice that this bode plot is the same as the plot from example 2.");         
  162.           prompt
  163.           closeplot
  164.  
  165.         elseif( k1 == 2 )
  166.           disp("")
  167.           clc
  168.           disp("\nDiscrete system bode analysis\n");
  169.           disp("Display bode plots of a discrete SISO system (dbode)\n")
  170.             disp("Example #1, Consider the following discrete transfer");
  171.           disp(" function:\n");
  172.           cmd = "sys1 = tf2sys([0.00100502 -0.00099502],[1 -2 1],0.001);";
  173.           disp(cmd);
  174.           eval(cmd);
  175.        cmd = "sysout(sys1)";
  176.           disp(cmd);
  177.           eval(cmd);
  178.             disp("\nTo examine open loop zeros and poles of the system,");
  179.           disp("use the command:\n")
  180.           cmd = "sysout(sys1,""zp"");";
  181.           run_cmd;      
  182.              disp("\nTo view the system's bode plots, execute the following");
  183.           disp("command:\n")
  184.             cmd = "bode(sys1);";
  185.           run_cmd;
  186.           disp("\nNotice (1) the plot label uses exp(jwT) for its title axis. This")
  187.           disp("           allows the user to determine what kind of system was")
  188.           disp("           used to generate the bode plot");
  189.           disp("       (2) the system poles are both at z=1, (break frequency at")
  190.           disp("           jwT = 0); pure integrator poles like this are discarded")
  191.           disp("           by Octave when computing the plot frequency range.")
  192.  
  193.           disp("\nIf magnitude, phase, and frequency data are also desired,");
  194.           disp(" perform the following command instead:\n");         
  195.           disp("[M,P,w]=dbode(num,den,T,wrange).\n Where:");
  196.           disp("M => Bode magnitude response data");
  197.           disp("P => Bode phase response data");
  198.           disp("w => frequencies that M and P were evaluated at");
  199.           disp("sys1 => system data structure")
  200.           disp("T => sample period")
  201.           disp("wrange => optional vector of frequencies")
  202.           disp("          if wrange is entered in the argument list, the");  
  203.           disp("      system will be evaluated at these specific"); 
  204.           disp("       frequencies\n"); 
  205.  
  206.           prompt
  207.           disp("")
  208.           clc    
  209.           disp("Example #2, Consider the following set of discrete poles and"); 
  210.           disp("zeros:\n")
  211.        cmd = "sys2 = zp2sys([0.99258;0.99745],[0.99961;0.99242],1,0.001);";
  212.           disp(cmd);
  213.        eval(cmd);
  214.           cmd = "sysout(sys2)";
  215.           disp(cmd);
  216.        eval(cmd);
  217.           disp("\nTo view the system's bode plots, execute the following");
  218.           disp("command:\n")
  219.             cmd = "bode(sys2);";
  220.           run_cmd;             
  221.           disp("Notice that the bode command is the same in both of the previous");
  222.           disp("examples.  The bode command is also the same for the continuous case.");
  223.           disp("The function, dbode, is no longer used.");
  224.  
  225.           prompt
  226.           disp("")
  227.           clc
  228.           disp("\nExample #3, Now consider the following state space system:\n");
  229.           cmd = "sys3 = ss2sys([.857 .0011;0 .99930],[1;1],[-.6318 .0057096],5.2, .001);";
  230.           disp(cmd);
  231.           eval(cmd);
  232.           cmd = "sysout(sys3);";
  233.           disp(cmd);
  234.           eval(cmd);
  235.           disp("\nTo view the system's bode plots, execute the following command:\n")
  236.             cmd = "bode(sys3);";
  237.              run_cmd;
  238.           disp("\nAgain, notice that the bode command is the same regardless of the form");
  239.           disp("of the system.");
  240.           disp("\nSuppose the user is interested in the response of the system");
  241.           disp("defined over the input frequency range of 1 - 1000 rad/s.\n");
  242.           disp("First, a frequency vector is required.  It can be created");
  243.           disp("with the command:\n");
  244.           cmd = "wrange = logspace(log10(1),log10(1000),100);";
  245.           disp(cmd); 
  246.           eval(cmd);
  247.           disp("\nThis creates a logrithmetically scaled frequency vector with");
  248.           disp("100 values between 1 and 1000 rad/s\n");
  249.           disp("Then, the bode command includes wrange in the input arguments");
  250.           disp("like this:");
  251.           cmd = "bode(sys3,wrange);";
  252.           run_cmd;
  253.           prompt;      
  254.           
  255.           disp("")
  256.           clc
  257.           disp("\nExample #4, We will now examine a MIMO state-space system.  Systems");
  258.           disp("two and three will be grouped.");
  259.           cmd = "[nn,nz] = sysdimensions(sys2);";
  260.           disp(cmd); eval(cmd);
  261.           cmd = "sys2 = syssetsignals(sys2,\"out\",\"y_sys2\");";
  262.           disp(cmd); eval(cmd);
  263.           cmd = "sys2 = syssetsignals(sys2,\"in\",\"u_sys2\");";
  264.           disp(cmd); eval(cmd);
  265.           cmd = "sys2 = syssetsignals(sys2,\"st\",sysdefioname(nn+nz,\"x_sys2\"));";
  266.           disp(cmd); eval(cmd);
  267.           cmd = "sys_mimo = sysgroup(sys2,sys3);";
  268.           disp(cmd); eval(cmd);
  269.           cmd = "sysout(sys_mimo);";
  270.           disp(cmd);
  271.           eval(cmd);
  272.           disp("\nTo view the system's bode plots, execute the following command:\n")
  273.             cmd = "bode(sys_mimo);";
  274.           run_cmd;
  275.           prompt
  276.  
  277.           disp("\nThe bode plot of a single channel is viewed as follows:")
  278.           cmd = "wrange = [];";
  279.           disp(cmd)
  280.           eval(cmd);
  281.           cmd = "out = 1;";
  282.           disp(cmd)
  283.           eval(cmd);
  284.           cmd = "in = 1;";
  285.           disp(cmd)
  286.           eval(cmd);
  287.           cmd = "bode(sys_mimo,wrange,out,in);";
  288.           run_cmd;
  289.           disp("\nNotice that this bode plot is the same as the plot from example 2.");         
  290.           prompt
  291.           closeplot
  292.  
  293.         elseif( k1 == 3 )
  294.           help bode
  295.           prompt
  296.         endif
  297.       endwhile
  298.     elseif (j == 2)
  299.       k2 = 0;
  300.       disp("");
  301.       while (k2 != 4)
  302.         disp("\n");
  303.         help nyquist
  304.         prompt;
  305.         disp("")
  306.         clc;
  307.  
  308.         k2 = menu("Nyquist analysis (Nyquist)",...
  309.                   'Continuous system nyquist analysis',...
  310.               'Discrete system nyquist analysis',...
  311.               'Mixed system nyquist analysis',...
  312.                   'Return to frdemo menu');
  313.  
  314.         if( k2 == 1 )
  315.           disp("")
  316.           clc
  317.        disp("\nContinuous system nyquist analysis\n");
  318.             disp("Display Nyquist plots of a SISO system (nyquist)\n")
  319.             disp("Example #1, Consider the following transfer function:\n")
  320.           cmd = "sys1 = tf2sys([1],[1 0.8 1]);";
  321.           disp(cmd);
  322.           eval(cmd);
  323.           disp("To examine the transfer function, use the command:");
  324.           cmd = "sysout(sys1);";
  325.           disp(cmd);
  326.           eval(cmd);
  327.           disp("\nTo examine the open loop zeros and poles, use the command:");
  328.           cmd = "sysout(sys1,""zp"");";
  329.           run_cmd;
  330.             disp("\nTo view the system""s nyquist plot, execute the following"); 
  331.           disp("command:\n")
  332.             cmd = "nyquist(sys1);";
  333.           run_cmd;
  334.           disp("\nIf the real and imaginary parts of the response are desired,");
  335.           disp("use the following command:");
  336.              disp("command: [R,I,w]=nyquist(sys1);\n");
  337.             disp("If the user desires to evaluate the response in a certain");
  338.           disp("frequency range, he may do so by entering the following:");
  339.           disp("command: [M,P,w]=nyquist(num,den,wrange).\n")
  340.             disp("wrange is a vector of frequencies that spans the desired");
  341.           disp("viewing range.\n");
  342.             disp("This will be illustrated in the third nyquist example.\n")  
  343.              disp("Variable Description:\n")
  344.             disp("R => real part of response")
  345.             disp("I => imaginary part of response")
  346.             disp("w => frequencies that the transfer function was evaluated at")
  347.             disp("sys1 => system data structure")
  348.              disp("wrange => optional vector of frequencies")
  349.           disp("          if wrange is entered in the argument list, the");
  350.           disp("      system will be evaluated at these specific");
  351.           disp("          frequencies\n") 
  352.           prompt 
  353.           
  354.           disp("")
  355.           clc
  356.           disp("Example #2, Consider the following set of poles and zeros:\n")
  357.           cmd = "sys2 = zp2sys([-1;-4],[-2+1.4142i;-2-1.4142i],1);";
  358.           disp(cmd);
  359.           eval(cmd);
  360.           disp("\nTo examine the poles and zeros, use the command:");
  361.           cmd = "sysout(sys2)";
  362.           disp(cmd);
  363.           eval(cmd);
  364.             disp("\nTo view the system""s nyquist plot, execute the following");
  365.           disp("command:\n")
  366.             cmd = "nyquist(sys2);";
  367.           run_cmd;
  368.           prompt
  369.  
  370.           disp("")
  371.           clc
  372.           disp("\nExample #3, Consider the following state space system:\n")
  373.           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);";
  374.           disp(cmd);
  375.           eval(cmd); 
  376.           disp("\nTo examine the state-space system, use the command:");
  377.           cmd = "sysout(sys3)";
  378.           disp(cmd);
  379.           eval(cmd);      
  380.           disp("\nTo examine the poles and zeros, use the command:");
  381.           cmd = "sysout(sys3,""zp"")";
  382.           run_cmd;
  383.             disp("\nTo view the system""s nyquist plot, execute the following");
  384.           disp("commands:\n")
  385.             cmd = "nyquist(sys3);";
  386.           run_cmd;
  387.           prompt     
  388.           
  389.           disp("Example #3 (continued), If the user wishes to evaluate the");
  390.           disp("system response over a desired frequency range, he must first");
  391.           disp("create a frequency vector.\n")
  392.             disp("For example, suppose the user is interested in the response");
  393.           disp("of the system defined above over input frequency range of");
  394.           disp("3 - 100 rad/s.\n")
  395.             disp("A frequency vector can be created using the command:\n");
  396.            cmd = "wrange = logspace(log10(3),log10(100),100);";
  397.           disp(cmd);
  398.           eval(cmd); 
  399.           disp("\nNyquist can be run again using the frequency vector as");
  400.           disp("follows:\n")
  401.              cmd = "nyquist(sys3,wrange);";
  402.           run_cmd;      
  403.           prompt
  404.  
  405.           disp("")
  406.           clc
  407.           disp("Example #4,  Nyquist can be used for MIMO systems if the system has");
  408.           disp("an equal number of inputs and outputs.  Otherwise, nyquist returns");
  409.           disp("an error.  To examine a MIMO system, systems 2 and 3 will be grouped");
  410.           cmd = "[nn,nz] = sysdimensions(sys2);";
  411.           disp(cmd); eval(cmd);
  412.           cmd = "sys2 = syssetsignals(sys2,\"out\",\"y_sys2\");";
  413.           disp(cmd); eval(cmd);
  414.           cmd = "sys2 = syssetsignals(sys2,\"in\",\"u_sys2\");";
  415.           disp(cmd); eval(cmd);
  416.           cmd = "sys2 = syssetsignals(sys2,\"st\",sysdefioname(nn+nz,\"x_sys2\"));";
  417.           disp(cmd); eval(cmd);
  418.           cmd = "sys_mimo = sysgroup(sys2,sys3);";
  419.           disp(cmd); eval(cmd);
  420.           cmd = "sysout(sys_mimo);";
  421.           disp(cmd);
  422.           eval(cmd);
  423.           disp("\nTo view the system's nyquist plot, execute the following command:\n")
  424.             cmd = "nyquist(sys_mimo);";
  425.        run_cmd;
  426.           prompt
  427.           disp("\nTo view the nyquist plots for selected  channels, the command form changes:")
  428.           cmd = "nyquist(sys_mimo,[],1,1);";
  429.           run_cmd;
  430.           disp("\nNotice that this bode plot is the same as the plot from example 2.");         
  431.           prompt
  432.           closeplot
  433.  
  434.  
  435.  
  436.         elseif( k2 == 2 )
  437.           disp("")
  438.           clc 
  439.           disp("\nDiscrete system nyquist analysis\n");
  440.             disp("Display Nyquist plots of a discrete SISO system (nyquist)\n")
  441.           disp("We will first define a sampling time, T");
  442.           cmd = "T = 0.01;";
  443.           disp(cmd); 
  444.           eval(cmd);
  445.             disp("\nExample #1, Consider the following transfer function:\n")
  446.             cmd = "sys1 = tf2sys([2 -3.4 1.5],[1 -1.6 0.8],T);";
  447.           disp(cmd); 
  448.           eval(cmd);
  449.           disp("To examine the transfer function, use the command:");
  450.           cmd = "sysout(sys1);";
  451.           disp(cmd);
  452.           eval(cmd);
  453.           disp("\nTo examine the open loop zeros and poles, use the command:");
  454.           cmd = "sysout(sys1,""zp"")";
  455.           disp(cmd); 
  456.           eval(cmd); 
  457.             disp("\nTo view the system""s nyquist plot, execute the following"); 
  458.           disp("command:")
  459.             cmd = "nyquist(sys1);";
  460.           run_cmd;
  461.           disp("To change the range used for the frequency, a frequency");
  462.           disp("is needed.  Suppose the user would like to examine the");
  463.           disp("nyquist plot in the frequency range of 0.01 - 31.6 rad/s.");
  464.           disp("\nThe frequency vector needed to do this is created with the");
  465.           disp("command:");
  466.           cmd = "wrange = logspace(-2,1.5,200);";
  467.           disp(cmd); 
  468.           eval(cmd);    
  469.           disp("\nNyquist can be run again with this frequency vector");         
  470.           cmd = "nyquist(sys1,wrange);";
  471.           run_cmd;
  472.             disp("\nIf the real and imaginary parts of the response are desired,");
  473.           disp("perform the following command:\n");     
  474.           disp("[R,I,w]=nyquist(sys,wrange)\n")
  475.           disp("Variable Description:\n")
  476.           disp("R => real part of response")
  477.            disp("I => imaginary part of response")
  478.             disp("w => frequencies that the transfer function was evaluated at")
  479.           disp("sys => The system data structure");
  480.             disp("wrange => optional vector of frequencies")
  481.             disp("          if wrange is entered in the argument list, the");
  482.           disp("      system will be evaluated at these specific");
  483.           prompt
  484.  
  485.           disp("")
  486.           clc
  487.           disp("\nExample #2, Consider the following set of poles and zeros:\n")
  488.              cmd = "sys2 = zp2sys([0.98025 + 0.01397i;0.98025 - 0.01397i],[0.96079;0.99005],1,T);";
  489.           disp(cmd); 
  490.           eval(cmd);
  491.           disp("\nTo examine the open loop zeros and poles, use the command:");
  492.           cmd = "sysout(sys2)";
  493.           disp(cmd); 
  494.           eval(cmd); 
  495.             disp("\nTo view the system's nyquist plot between the frequencies");
  496.           disp("0.01 - 100 rad/s, execute the following commands:\n")
  497.             cmd = "wrange = logspace(-2,2,100);";
  498.           disp(cmd); 
  499.           eval(cmd);
  500.         cmd = "nyquist(sys2,wrange);";
  501.           run_cmd;
  502.           prompt;
  503.         
  504.           disp("")
  505.           clc
  506.           disp("\nExample #3, Consider the following discrete state space");
  507.           disp("system:\n");
  508.           disp("This example will use the same system used in the third");
  509.           disp("example in the continuous nyquist demo.  First, that system");
  510.           disp("will have to be re-entered useing the following commands:\n");
  511.           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);";
  512.           disp(cmd); 
  513.           eval(cmd); 
  514.           disp("\nTo examine the state-space system, use the command:");
  515.           cmd = "sysout(sys3)";
  516.           disp(cmd); 
  517.           eval(cmd);
  518.           disp("\nTo examine the poles and zeros, use the command:");
  519.           cmd = "sysout(sys3,""zp"")";
  520.           disp(cmd); 
  521.           eval(cmd);
  522.           disp("\nTo convert the system to discrete time, we need a sampling");
  523.           disp("time which can be entered like this:");
  524.           cmd = "T = 0.01";
  525.           disp(cmd); 
  526.           eval(cmd);
  527.           disp("\nNow the command, c2d, is used to convert the system from");
  528.           disp("continuous to discrete time, with the following command");
  529.           cmd = "dsys3 = c2d(sys3,T);";
  530.           run_cmd;
  531.           disp("\nTo examine the new discrete state-space system, use the");
  532.           disp("command");
  533.           cmd = "sysout(dsys3);";
  534.           disp(cmd); 
  535.           eval(cmd);
  536.        disp("\nTo examine the new discrete poles and zeros, use the command:");
  537.           cmd = "sysout(dsys3,""zp"")";
  538.           disp(cmd); 
  539.           eval(cmd);
  540.           disp("\nTo view the system's nyquist plot, execute the following");
  541.           disp("commands:\n");
  542.        cmd = "gset xrange [-4:2];";
  543.           disp(cmd); eval(cmd);
  544.           cmd = "gset yrange [-2.5:2.5];";
  545.           disp(cmd); eval(cmd);
  546.           cmd = "nyquist(dsys3);";
  547.            run_cmd;
  548.       disp("Notice that the asymptotes swamp out the behavior of the plot")
  549.           disp("near the origin.  You may use interactive nyquist plots")
  550.           disp("to \"zoom in\" on a plot as follows:")
  551.  
  552.           cmd = "atol = 1;";
  553.           disp(cmd)
  554.           eval(cmd)
  555.           cmd = "nyquist(dsys3,[],[],[],atol);";
  556.           run_cmd
  557.           prompt
  558.  
  559.  
  560.           disp("")
  561.           clc
  562.           disp("MIMO SYSTEM:  Nyquist cannot be used for discrete MIMO systems");
  563.           disp("at this time.");
  564. #      cmd = "dsys_mimo = sysgroup(sys2,dsys3);";
  565. #          disp(cmd);
  566. #      eval(cmd);
  567. #      cmd = "sysout(dsys_mimo);";
  568. #      disp(cmd);
  569. #      eval(cmd);
  570. #      disp("\nTo view the system's nyquist plot, execute the following command:\n")
  571. #            cmd = "nyquist(dsys_mimo);";
  572. #      run_cmd;       
  573. #          prompt
  574. #       disp("\nTo view the nyquist plots for selected  channels, the command form changes:")
  575. #          cmd = "nyquist(dsys_mimo,[],1,1);";
  576. #      run_cmd;
  577. #      disp("\nNotice that this bode plot is the same as the plot from example 2.");         
  578.           prompt
  579.           closeplot
  580.  
  581.                
  582.         elseif( k2 == 3 )
  583.           disp("\nMixed system nyquist analysis\n");
  584.           disp("Nyquist exits with an error if it is passed a ""mixed"" system (one")
  585.           disp("with both continuous and discrete states).  Use c2d or d2c to")
  586.           disp("convert the system to either pure digital or pure continuous form");
  587.         endif
  588.       endwhile 
  589.     elseif (j == 3)
  590.       help nichols
  591.       prompt
  592.     endif
  593.   endwhile
  594. endfunction
  595.