How do I model a transfer function with coefficients that vary with simulation time in Simulink 7.5 (R2010a)?

68 views (last 30 days)
I want to create a model containing a "Transfer Function" block or a State Space matrix system. The numerator and denominator coefficients for the transfer function or the A,B,C,D matrices should change as function of time, or a scheduling variable, or signal. How can I achieve this in Simulink?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 21 Dec 2011
There are several methods that may be used to implement time varying transfer functions. Your choice of the specific method will be influenced by your specific needs and situation. If you wish to have total control over the state of your state space system's state or if you wish to update your state via code, consider option 1. If you wish to be able to interpolate between known discrete transfer functions as a function of a scheduling variable, consider option 2. If you wish to vary a parameter in a low order process model transfer function such as a damping coefficient, consider option 3. If you wish to vary a parameter in a state space matrix system, such as a spring constant, consider option 4.
NOTE: By definition, a time-varying LTI transfer function is an approximation since it is assumed that these varying coefficients are time-independent. Therefore, you must exercise judgment in your application. Typically, if the coefficients of the system are varied very slowly with respect to the rest of the dynamics of the system, this can be an acceptable approximation. Alternatively, if you perform instantaneous changes to the coefficients, you may need to assume a certain amount of "error" at the moment of transition.
1) S-Functions allow for a framework where you can directly perform the state update and propagation of a transfer function. This allows you to change the transfer function coefficients according to some externally fed scheduling variable and update the state of the transfer function accordingly. An example of this is in the MATLAB shipping S-function demos, title "Time Varying Continuous Transfer Function block". To navigate there, type "sfundemos" at the MATLAB command window and navigate to C-file S-Functions -> Continuous -> Time varying continuous transfer function. Level 2, MATLAB Files S-Functions may also be used in a similar method.
2) The block "Time Fcn Direct Form II Time Varying" allows for a block approach. This is located in the library under Simulink -> Additional Math & Discrete -> Additional Discrete library. You can use this block to implement discrete transfer functions that can vary according to some sort of scheduling variable. See the example "TimeVaryDFII.mdl" in the attached files, and see the documentation for further details in working with this block.
3) You can breakdown any given SISO transfer function into components of Y(s), and U(s) that are gains multiplied by varying powers of 1/s. The gains may be replaced with multiplication blocks and tunable constant blocks or other signals that may change as a function of time. If you construct the transfer function from these components, the gain values are tunable and can be varied according to a scheduling variable within the model. See the example "ComponentTF.mdl"
4) A similar method may be applied to state space MIMO matrices. See the example model "ComponentSS.mdl" which implements a double spring / mass / damper system and varies the damper c1.

Sign in to comment.

More Answers (2)

Oswald on 28 Nov 2016
Perfect examples !

Huayu Li
Huayu Li on 12 Jul 2017
Perfect answers and examples. Thanks very much for your help ^^

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!