Detailed instructions for use are in the User's Guide.
[. . . ] Simulink® Control DesignTM 3 User's Guide
How to Contact MathWorks
Web Newsgroup www. mathworks. com/contact_TS. html Technical Support
www. mathworks. com comp. soft-sys. matlab suggest@mathworks. com bugs@mathworks. com doc@mathworks. com service@mathworks. com info@mathworks. com
Product enhancement suggestions Bug reports Documentation error reports Order status, license renewals, passcodes Sales, pricing, and general information
508-647-7000 (Phone) 508-647-7001 (Fax) The MathWorks, Inc. 3 Apple Hill Drive Natick, MA 01760-2098
For contact information about worldwide offices, see the MathWorks Web site. Simulink® Control DesignTM User's Guide © COPYRIGHT 20042010 by The MathWorks, Inc.
The software described in this document is furnished under a license agreement. The software may be used or copied only under the terms of the license agreement. [. . . ] In this case, you find the operating point from simulation of the model.
magball op=findop('magball', 20);
Next, compute the open-loop model seen by the block magball/Controller, with the getlinplant function.
[sysp, sysc]=getlinplant('magball/Controller', op)
The output variable sysp gives the open-loop plant model as follows:
a= Current dhdt height b= Current Controller 50 Current -100 -2. 801 0 dhdt 0 0 1 height 0 196. 2 0
7-81
getlinplant
dhdt height c= Sum2 d= Sum2 Controller 0 Current 0
0 0
dhdt 0
height -1
Continuous-time model.
See Also
findop, linoptions, operpoint, operspec
7-82
getstatestruct
Purpose Syntax Description
State structure from operating point
x_struct = getstatestruct(op_point) x_struct = getstatestruct(op_point) extracts a structure of state values, x_struct, from the operating point object, op_point. The structure, x_struct, uses the same format as Simulink software which allows you to set initial values for states in the model within the Data Import/Export pane of the Configuration Parameters dialog box.
Example
Create an operating point object for the magball model:
op_magball=operpoint('magball');
Extract a state structure from the operating point object:
states_magball=getstatestruct(op_magball)
This extraction returns
states_magball = time: 0 signals: [1x5 struct]
To view the values of the states within this structure, use dot-notation to access the values field:
states_magball. signals. values
This dot-notation returns
ans = 0
ans =
7-83
getstatestruct
14. 0071
ans = 7. 0036
ans = 0
ans = 0. 0500
See Also
getinputstruct, getxu, operpoint
7-84
getxu
Purpose Syntax
States and inputs from operating points
x = getxu(op_point) [x, u] = getxu(op_point) [x, u, xstruct] = getxu(op_point) x = getxu(op_point) extracts a vector of state values, x, from the operating point object, op_point. The ordering of states in x is the same
Description
as that used by Simulink software.
[x, u] = getxu(op_point) extracts a vector of state values, x, and a vector of input values, u, from the operating point object, op_point. States in x and inputs in u are ordered in the same way as for Simulink. [x, u, xstruct] = getxu(op_point) extracts a vector of state values, x, a vector of input values, u, and a structure of state values, xstruct, from the operating point object, op_point. The structure of state values, xstruct, has the same format as that returned from a Simulink simulation. States in x and xstruct and inputs in u are ordered in the
same way as for Simulink.
Example
Create an operating point object for the magball model by typing:
op=operpoint('magball');
To view the states within this operating point, type:
op. States
which returns
(1. ) magball/Controller/PID Controller/Filter x: 0 (2. ) magball/Controller/PID Controller/Integrator x: 14 (3. ) magball/Magnetic Ball Plant/Current x: 7 (4. ) magball/Magnetic Ball Plant/dhdt
7-85
getxu
x: 0 (5. ) magball/Magnetic Ball Plant/height x: 0. 05
To extract a vector of state values, with the states in an ordering that is compatible with Simulink, along with inputs and a state structure, type:
[x, u, xstruct]=getxu(op)
This syntax returns:
x= 0. 0500 0 14. 0071 7. 0036 0
u= []
xstruct = time: 0 signals: [1x5 struct]
View xstruct in more detail by typing:
xstruct. signals
This syntax displays:
ans =
7-86
getxu
1x5 struct array with fields: values dimensions label blockName stateName inReferencedModel sampleTime
View each component of the structure individually. For example:
xstruct. signals(1). values ans = 0
or
xstruct. signals(2). values ans = 7. 0036
You can import these vectors and structures into Simulink as initial conditions or input vectors or use them with setxu, to set state and input values in another operating point.
See Also
operpoint, operspec
7-87
initopspec
Purpose Syntax
Initialize operating point specification values
opnew=initopspec(opspec, oppoint) opnew=initopspec(opspec, x, u) opnew=initopspec(opspec, xstruct, u)
Graphical Interface
As an alternative to the initopspec function, initialize operating point specification values in the Create Operating Points pane in the Operating Points node within the Simulink Control Design GUI. See "Steady-State Operating Points (Trimming) From Specifications" on page 1-12.
opnew=initopspec(opspec, oppoint) initializes the operating point
Description
specification object, opspec, with the values contained in the operating point object, oppoint. The function returns a new operating point specification object, opnew. Create opspec with the function operspec. Create oppoint with the function operpoint or findop.
opnew=initopspec(opspec, x, u) initializes the operating point specification object, opspec, with the values contained in the state vector, x, and the input vector, u. The function returns a new operating point specification object, opnew. Create opspec with the function operspec. You can use the function getxu to create x and u with the correct ordering. opnew=initopspec(opspec, xstruct, u) initializes the operating point
specification object, opspec, with the values contained in the state structure, xstruct, and the input vector, u. The function returns a new operating point specification object, opnew. Create opspec with the function operspec. You can use the function getstatestruct or getxu to create xstruct and the function getxu to create u with the correct ordering. Alternatively, you can save xstruct to the MATLAB workspace after a simulation of the model. See the Simulink documentation for more information on these structures.
Example
Create an operating point using findop by simulating the magball model and extracting the operating point after 20 time units.
7-88
initopspec
oppoint=findop('magball', 20)
This syntax returns the following operating point:
Operating Point for the Model magball. (Time-Varying Components Evaluated at time t=20) States: ---------(1. ) magball/Controller/PID Controller/Filter x: 2. 33e-007 (2. ) magball/Controller/PID Controller/Integrator x: 14 (3. ) magball/Magnetic Ball Plant/Current x: 7 (4. ) magball/Magnetic Ball Plant/dhdt x: 3. 6e-008 (5. ) magball/Magnetic Ball Plant/height x: 0. 05 Inputs: None ----------
Use these operating point values as initial values in an operating point specification object.
opspec=operspec('magball'); newopspec=initopspec(opspec, oppoint)
The new operating point specification object is displayed.
Operating Specification for the Model magball. [. . . ] Choose the trigger type in the Block Parameters dialog box, as shown in the following figure.
The possible trigger types are · rising: the signal crosses zero while increasing. · falling: the signal crosses zero while decreasing. · either: the signal crosses zero while either increasing or decreasing. · function-call: the signal send a function call. [. . . ]