annotate scripts/control/sysrepdemo.m @ 3279:6dd06d525de6

[project @ 1999-10-12 16:52:40 by jwe]
author jwe
date Tue, 12 Oct 1999 16:53:06 +0000
parents 98e15955107e
children f7e4a95916f2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3279
6dd06d525de6 [project @ 1999-10-12 16:52:40 by jwe]
jwe
parents: 3236
diff changeset
1 # Copyright (C) 1996,1998 Auburn University. All Rights Reserved
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
2 #
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
3 # This file is part of Octave.
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
4 #
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
5 # Octave is free software; you can redistribute it and/or modify it
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
6 # under the terms of the GNU General Public License as published by the
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
7 # Free Software Foundation; either version 2, or (at your option) any
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
8 # later version.
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
9 #
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
10 # Octave is distributed in the hope that it will be useful, but WITHOUT
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
13 # for more details.
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
14 #
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
15 # You should have received a copy of the GNU General Public License
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
16 # along with Octave; see the file COPYING. If not, write to the Free
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
17 # Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
18
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
19 function sysrepdemo()
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
20
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
21 # Octave Controls toolbox demo: System representation
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
22
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
23 # Written by A. S. Hodel June 1995
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
24 # Revised Aug 1995 for system data structure format
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
25
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
26 save_val = page_screen_output;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
27 page_screen_output = 1;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
28
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
29 disp('System representation demo:')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
30 num = [5 -1];
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
31 denom = [1 -2 6];
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
32 a = b = c = [];
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
33 syschoice = -1;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
34 ch_init = 2;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
35 ch_extract = ch_init+1;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
36 ch_update = ch_extract+1;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
37 ch_view = ch_update+1;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
38 ch_details = ch_view+1;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
39 ch_quit = ch_details+1;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
40 while(syschoice != ch_quit)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
41 disp(" ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
42 syschoice = menu('Octave System Representation Menu', ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
43 "General overview of system representation (DO THIS FIRST)", ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
44 "Initialize a system (ss2sys, tf2sys, zp2sys)", ...
3228
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
45 "Extract data from a system(sys2ss, sys2tf, sys2zp, etc.)", ...
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
46 "Update internal representation (sysupdate)", ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
47 "View the internal contents of a system (sysout)", ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
48 "Details of internal representation", ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
49 "Return to main menu");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
50 if(syschoice == 1) # general overview
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
51 disp("The Octave Control Systems Toolbox (OCST) was designed to")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
52 disp("provide a simple user interface to a powerful set of tools.")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
53 disp(' ')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
54 disp(' ----------')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
55 disp(' input(s) ---->| System | ---> output(s) ')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
56 disp(' ----------')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
57 disp(' ')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
58 disp("Like other computer-aided control system design tools, the OCST")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
59 disp("enables users to enter their descriptions of dynamic systems in ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
60 disp("their preferred form (state space, transfer function, or ");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
61 disp("zero-pole format). ");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
62 disp("The OCST stores system descriptions in a single variable data ");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
63 disp("structure that allows for continuous time, discrete-time, or mixed ");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
64 disp("(sampled-data) systems. ");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
65 disp(" ");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
66 disp("This single variable description of dynamic systems greatly simplifies ");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
67 disp("both the code of the OCST as well as the user interface, since only")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
68 disp("one variable is passed per system, regardless of the internal ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
69 disp("representation used in the data structure. As a result, the ");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
70 disp("likelihood of user error is greatly reduced when calling OCST")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
71 disp("functions. Further, all OCST functions have been written to")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
72 disp("provide meaningful warning or error message to assist the user")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
73 disp("in correcting their programming errors while using the OCST.")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
74 disp("The details of the internal representation can be seen in ");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
75 disp(["menu option ",num2str(ch_details)]);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
76 disp("The data structure used in the OCST is called a \"system data structure.\"");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
77 disp("A system data structure is contstructed with one of:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
78 disp(" fir2sys (FIR transfer function to system)")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
79 disp(" ss2sys (state space matrices to system)")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
80 disp(" tf2sys (SISO transfer function to system)")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
81 disp(" zp2sys (SISO zero/pole/leading coefficient to system)")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
82 disp(" ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
83 disp(["These functions are discussed in in menu option ",num2str(ch_init)])
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
84 disp("The data in a system may be extracted using ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
85 disp(" sys2fir (FIR transfer function from system")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
86 disp(" sys2ss (state space matrices from system)")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
87 disp(" sys2tf (SISO transfer function from system)")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
88 disp(" sys2zp (SISO zero/pole/leading coefficient from system)")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
89 disp(" ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
90 disp(["These functions are discussed in menu option ", ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
91 num2str(ch_extract)]);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
92 disp("Other options discussed under this menu are updating the internal")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
93 disp("representation form of a system data structure with sysupdate and printing")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
94 disp("the description of a dynamic system to the screen with sysout.")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
95 disp(" ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
96 disp("Once the user is familiar with these commands, the rest of the ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
97 disp("OCST package will be quite easy to use.")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
98 elseif(syschoice == ch_init) % Initialize
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
99 disp("Initialization of a system:");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
100 disp(' ');
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
101 formopt = 0;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
102 while(formopt != 4)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
103 disp("Three data formats may be used to initialize a system:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
104 formopt = menu("System data structure initialization menu", ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
105 "State space form (ss2sys)", ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
106 "Transfer function form (tf2sys)", ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
107 "zero-pole form (zp2sys)", ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
108 "Return to System representation menu");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
109 if(formopt == 1)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
110 disp('State space representation of a system is based on the usual')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
111 disp('multi-variable differential equations')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
112 disp(' ')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
113 disp(' . ')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
114 disp(' x = A x + B u -or - x(k+1) = A x(k) + B u(k) ')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
115 disp(' y = C x + D u y(k) = C x(k) + D u(k) ')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
116 disp(' ')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
117 disp('for matrices A, B, C, D of appropriate dimension.')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
118 disp(' ')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
119 ssopt = 0;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
120 ssquit = 5;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
121 while(ssopt < ssquit)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
122 ssopt = menu("State space initialization examples", ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
123 "Double integrator example", ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
124 "Double delay (discrete-time) example", ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
125 "Summing junction (D-matrix only) example", ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
126 "ss2sys details (help ss2sys)", ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
127 "return to system initialization menu", ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
128 "return to system representation main menu");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
129 if(ssopt == 1)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
130 disp("Example: construct a system representation of a")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
131 disp("double integrator via state-space form")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
132 cmd = "a = [0 1; 0 0];";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
133 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
134 cmd = "b = [0 ; 1];";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
135 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
136 cmd = "c = [1 0];";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
137 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
138 cmd = "sys = ss2sys(a,b,c);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
139 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
140 disp("The state space form of the system is seen via sysout:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
141 cmd = "sysout(sys)";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
142 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
143 disp("Notice that the Octave controls toolbox automatically")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
144 disp("assigns names to the states, inputs and outputs,")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
145 disp("and that the D matrix was filled in automatically.")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
146 disp("We verify that it's a double integrator via sysout:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
147 cmd = "sysout(sys,""tf"")";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
148 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
149 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
150 elseif(ssopt == 2)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
151 disp("Example: discrete-time double-delay:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
152 disp("This example is identical to the double-integrator,")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
153 disp("except that it is a discrete-time system, and so has")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
154 disp("a sampling interval. We arbitrarily select T=1e-3.");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
155 cmd = "a = [0 1; 0 0];";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
156 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
157 cmd = "b = [0 ; 1];";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
158 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
159 cmd = "c = [1 0];";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
160 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
161 cmd = "sys=ss2sys(a,b,c,[],1e-3);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
162 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
163 cmd = "sysout(sys)";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
164 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
165 disp("Notice that the D matrix was filled in automatically.")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
166 disp("This is done if D is input as the empty matrix.")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
167 disp(" ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
168 disp("Notice also that the output y_1 is labelled as a discrete")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
169 disp("output. The OCST data structure keeps track of states")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
170 disp("and output signals that are produced by the discrete-time")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
171 disp("portion of a system. Discrete states and outputs are ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
172 disp("implemented as shown in the block diagram below:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
173 disp(" ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
174 disp(" ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
175 disp(" _________ ________ x(kT) ________________")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
176 disp("f(t)-->|sampler|-->| delay |----->|zero order hold| -->")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
177 disp(" --------- -------- ----------------")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
178 disp(" ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
179 disp(" ___________ _______________")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
180 disp("f(t)-->| sampler |-->|zero-order hold| --> y(discrete)")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
181 disp(" ----------- ---------------")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
182 disp(" ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
183 disp("where f(t) is an input signal to either the output or the")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
184 disp(" discrete state.")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
185 disp(" ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
186 disp("The OCST does not implement samplers on inputs to continuous")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
187 disp("time states (i.e., there are no samplers implicit in the B")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
188 disp("or D matrices unless there are corresponding discrete")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
189 disp("outputs or states. The OCST provides warning messages when")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
190 disp("if this convention is violated.")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
191 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
192 elseif(ssopt == 3)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
193 disp("A summing junction that computes e(t) = r(t) - y(t) may be");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
194 disp("constructed as follows:");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
195 disp("First, we set the matrix D:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
196 cmd = "D = [1 -1];";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
197 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
198 disp("ss2sys allows the initialization of signal and state names")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
199 disp("(see option 4), so we initialize these as follows:")
3228
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
200 cmd = "inname = list(\"r(t)\",\"y(t)\");";
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
201 run_cmd;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
202 cmd = "outname = \"e(t)\";";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
203 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
204 disp("Since the system is continous time and without states,")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
205 disp("the ss2sys inputs tsam, n, and nz are all zero:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
206 cmd = "sys = ss2sys([],[],[],D,0,0,0,[],inname,outname);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
207 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
208 disp("The resulting system is:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
209 cmd = "sysout(sys)";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
210 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
211 disp("A discrete-time summing block can be implemented by setting")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
212 disp("the sampling time positive:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
213 cmd = "sys = ss2sys([],[],[],D,1e-3,0,0,[],inname,outname);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
214 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
215 disp("The resulting system is:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
216 cmd = "sysout(sys)";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
217 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
218 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
219 elseif(ssopt == 4)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
220 help ss2sys
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
221 disp(" ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
222 disp(" ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
223 disp("Notice that state-space form allows a single system to have")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
224 disp("both continuous and discrete-time states and to have both continuous")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
225 disp("and discrete-time outputs. Since it's fairly easy to make an")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
226 disp("error when mixing systems of this form, the Octave controls")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
227 disp("toolbox attempts to print warning messages whenever something")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
228 disp("questionable occurs.")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
229 elseif(ssopt == 6)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
230 formopt = 4; # return to main menu
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
231 endif
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
232 endwhile
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
233 elseif(formopt == 2)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
234 tfopt = 0;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
235 while(tfopt < 5)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
236 tfopt = menu("Transfer function initialization menu", ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
237 "Continuous time initialization" , ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
238 "Discrete time initialization" , ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
239 "User specified signal names" , ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
240 "tf2sys details (help tf2sys)", ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
241 "Return to system initialization menu", ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
242 "Return to system representation main menu");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
243 if(tfopt == 1) # continuous time
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
244 disp("A transfer function is represented by vectors of the")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
245 disp("coefficients of the numerator and denominator polynomials");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
246 disp(" ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
247 disp("For example: the transfer function");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
248 disp(" ");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
249 num = [5 -1];
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
250 denom = [1 -2 6];
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
251 tfout(num,denom);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
252 disp(" ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
253 disp("is generated by the following commands:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
254 cmd = "num = [5 -1]";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
255 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
256 cmd = "denom = [1 -2 6]";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
257 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
258 cmd = "sys = tf2sys(num,denom);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
259 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
260 disp("alternatively, the system can be generated in a single command:");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
261 cmd = "sys = tf2sys([5 -1],[1 -2 6]);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
262 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
263 disp("Notice the output of sys: it is an Octave data structure.")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
264 disp("The details of its member variables are explained under")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
265 disp("System Representation Menu option 5 (the details of system form)")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
266 disp(" ");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
267 disp("The data structure can be observed with the sysout command:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
268 cmd = "sysout(sys)";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
269 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
270 disp("Notice that Octave assigns names to inputs and outputs.")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
271 disp("The user may manually select input and output names; see option 3");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
272 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
273 elseif(tfopt == 2) # discrete time
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
274 disp("A transfer function is represented by vectors of the")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
275 disp("coefficients of the numerator and denominator polynomials");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
276 disp("Discrete-time transfer functions require ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
277 disp("the additional parameter of a sampling period:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
278 cmd = "sys=tf2sys([5 -1],[1 2 -6],1e-3);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
279 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
280 cmd = "sysout(sys)";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
281 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
282 disp("The OCST recognizes discrete-time transfer functions and")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
283 disp("accordingly prints them with the frequency domain variable z.");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
284 disp("Notice that Octave assigns names to inputs and outputs.")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
285 disp("The user may set input and output names; see option 3");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
286 elseif(tfopt == 3) # user specified names
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
287 disp("The OCST requires all signals to have names. The OCST assigned default");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
288 disp("names to the signals in the other examples. We may initialize a transfer");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
289 disp("function with user-specified names as follows: Consider a simple ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
290 disp("double-integrator model of aircraft roll dynamics with ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
291 disp("input \"aileron angle\" and output \"theta\". A ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
292 disp("system for this model is generated by the command")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
293 cmd = "aircraft=tf2sys(1,[1 0 0],0,\"aileron angle\",\"theta\");"; run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
294 disp("The sampling time parameter 0 indicates that the system")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
295 disp("is continuous time. A positive sampling time indicates a")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
296 disp("discrete-time system (or sampled data system).")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
297 cmd = "sysout(aircraft)";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
298 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
299 disp("Notice that the user-selected signal names are listed.")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
300 disp("These signal names are used in OCST plots and design functions.");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
301 disp("(Run the frequency response demo to see an example of the use of ");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
302 disp("signal names in plots.)")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
303 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
304 elseif(tfopt == 4) # help
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
305 help tf2sys
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
306 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
307 elseif(tfopt == 6) # return to main menu
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
308 formopt = 4;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
309 endif
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
310 endwhile
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
311 elseif (formopt == 3)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
312 zpopt = 0;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
313 while(zpopt < 5)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
314 zpopt = menu("Zero-pole initialization menu", ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
315 "Continuous time initialization" , ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
316 "Discrete time initialization" , ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
317 "User specified signal names" , ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
318 "zp2sys details (help zp2sys)", ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
319 "Return to system initialization menu", ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
320 "Return to system representation main menu");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
321 if(zpopt == 1) # continuous time
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
322 disp("A zero-pole form representation of a system includes vectors")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
323 disp("of the system poles and zeros and a scalar leading coefficient.");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
324 disp(" ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
325 disp("For example: the transfer function");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
326 disp(" ");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
327 k = 5;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
328 num = [5 -1];
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
329 denom = [1 -2 6];
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
330 zpout(num,denom,k);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
331 disp(" ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
332 disp("is generated by the following commands:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
333 cmd = "num = [5 -1]";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
334 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
335 cmd = "denom = [1 -2 6]";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
336 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
337 cmd = "k = 5";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
338 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
339 cmd = "sys = zp2sys(num,denom,k);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
340 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
341 disp("alternatively, the system can be generated in a single command:");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
342 cmd = "sys = zp2sys([5 -1],[1 -2 6],5);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
343 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
344 disp("Notice the output of sys: it is an Octave data structure.")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
345 disp("The details of its member variables are explained under")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
346 disp("System Representation Menu option 5 (the details of system form)")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
347 disp(" ");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
348 disp("The data structure can be observed with the sysout command:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
349 cmd = "sysout(sys)";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
350 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
351 disp("Notice that Octave assigns names to inputs and outputs.")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
352 disp("The user may manually select input and output names; see option 3");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
353 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
354 elseif(zpopt == 2) # discrete time
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
355 disp("A zero-pole form representation of a system includes vectors")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
356 disp("of the system poles and zeros and a scalar leading coefficient.");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
357 disp(" ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
358 disp("Discrete-time systems require the additional parameter of a sampling period:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
359 cmd = "sys=zp2sys([5 -1],[1 2 -6],5,1e-3);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
360 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
361 cmd = "sysout(sys)";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
362 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
363 disp("The OCST recognizes discrete-time transfer functions and")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
364 disp("accordingly prints them with the frequency domain variable z.");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
365 disp("Notice that Octave assigns names to inputs and outputs.")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
366 disp("The user may set input and output names; see option 3");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
367 elseif(zpopt == 3) # user specified names
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
368 disp("The OCST requires all signals to have names. The OCST assigned default");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
369 disp("names to the signals in the other examples. We may initialize a transfer");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
370 disp("function with user-specified names as follows: Consider a simple ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
371 disp("double-integrator model of aircraft roll dynamics with ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
372 disp("input \"aileron angle\" and output \"theta\". A ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
373 disp("system for this model is generated by the command")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
374 cmd = "aircraft=zp2sys([],[0 0],1,0,\"aileron angle\",\"theta\");"; run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
375 disp("The sampling time parameter 0 indicates that the system")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
376 disp("is continuous time. A positive sampling time indicates a")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
377 disp("discrete-time system (or sampled data system).")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
378 cmd = "sysout(aircraft)";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
379 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
380 disp("Notice that the user-selected signal names are listed.")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
381 disp("These signal names are used in OCST plots and design functions.");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
382 disp("(Run the frequency response demo to see an example of the use of ");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
383 disp("signal names in plots.)")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
384 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
385 elseif(zpopt == 4) # help
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
386 help zp2sys
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
387 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
388 elseif(zpopt == 6) # return to main menu
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
389 formopt = 4;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
390 endif
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
391 endwhile
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
392 endif
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
393 endwhile
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
394 elseif(syschoice == ch_extract) # extract system information
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
395 disp("Extract information from a system data structure in a selected format:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
396 disp("The actions of operations ss2sys, tf2sys, and zp2sys are reversed by")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
397 disp("respective functions sys2ss, sys2tf, and sys2zp. The latter two");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
398 disp("functions are applicable only to SISO systems.")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
399 formopt = 0;
3228
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
400 while(formopt != 8)
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
401 formopt = menu("Extract system information", ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
402 "in state space form (sys2ss)", ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
403 "in transfer function form (sys2tf)", ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
404 "in zero pole form (sys2zp)", ...
3228
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
405 "signal names (sysgetsignals,syssetsignals)", ...
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
406 "sampling time (sysgettsam)", ...
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
407 "signal dimensions (sysdimensions)", ...
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
408 "primary system type (sysgettype)", ...
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
409 "Return to system representation menu");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
410 if(formopt == 1)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
411 help sys2ss
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
412 elseif(formopt == 2)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
413 help sys2tf
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
414 elseif(formopt == 3)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
415 help sys2zp
3228
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
416 elseif(formopt == 4)
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
417 help sysgetsignals
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
418 cmd="sys=ss2sys(rand(4),rand(4,2),rand(3,4));";
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
419 run_cmd
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
420 printf("Example: All signals names can be extracted by\n");
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
421 cmd = "[Ast,Ain,Aout,Ayd] = sysgetsignals(sys)";
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
422 run_cmd
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
423 printf("Example: Input signal names can be extracted as\n");
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
424 cmd = "Ain = sysgetsignals(sys,\"in\")";
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
425 run_cmd
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
426 printf("Example: The name of output signal 2 can be extracted as\n");
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
427 cmd = "Aout = sysgetsignals(sys,\"out\",2)";
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
428 run_cmd
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
429 printf("\nNotice that Aout is returned as a list; the signal name\n");
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
430 printf("itself is obtained by specifying the input parameter strflg\n");
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
431 cmd = "Aout = sysgetsignals(sys,\"out\",2,1)";
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
432 run_cmd
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
433 prompt
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
434 cmd = "help syssetsignals";
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
435 run_cmd
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
436 printf("Example: set input 2 name to \"motor voltage\"\n");
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
437 cmd = "sys = syssetsignals(sys,\"in\",\"motor voltage\",2); sysout(sys)";
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
438 run_cmd
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
439
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
440 printf("Other syssetsignals demos are in the Block diagram demo program bddemo\n");
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
441 elseif(formopt == 5)
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
442 help sysgettsam
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
443 elseif(formopt == 6)
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
444 help sysdimensions
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
445 elseif(formopt == 7)
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
446 help sysgettype
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
447 endif
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
448 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
449 endwhile
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
450 elseif(syschoice== ch_update)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
451 disp("The OCST system data structure format will store a system in the same format")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
452 disp("as that with which it was initialized. For example, consider the following:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
453 cmd = "sys=zp2sys([1 2],[3 4 5],6)";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
454 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
455 disp(" ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
456 disp("Notice the internal variables in the structure include zer, pol, and k,")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
457 disp("the required variables for zero-pole form. We can update the system")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
458 disp("to include state-space form as follows:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
459 cmd = "sys = sysupdate(sys,\"ss\")";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
460 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
461 disp(" ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
462 disp("Now the sys data structure includes variables a, b, c, and d, as well")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
463 disp("the default state names stname. sysupdate is usually used internally in")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
464 disp("the OCST, but can be used manually if desired. A full description of")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
465 disp("sysupdate is as follows:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
466 help sysupdate
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
467 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
468 elseif(syschoice == ch_view)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
469 disp("The sysout command can be used to view a system in any desired format.")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
470 disp("For example, consider the system created as follows:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
471 cmd = "aircraft=zp2sys(1,[0 0],1,0,\"aileron angle\",\"theta\");"; run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
472 disp("The system may be viewed in its default format (zero-pole) as follows")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
473 cmd = "sysout(aircraft)";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
474 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
475 disp(" ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
476 disp("The system may be viewed in state-space or transfer function form as well:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
477 cmd = "sysout(aircraft,\"ss\")";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
478 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
479 cmd = "sysout(aircraft,\"tf\")";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
480 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
481 disp("A complete description of sysout is below:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
482 help sysout
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
483 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
484 elseif(syschoice == ch_details)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
485 packedform
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
486 endif
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
487
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
488 endwhile
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
489 page_screen_output = save_val;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
490 endfunction
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
491