Skip to main content

Vector-Matrix Algebra and the State-Space Representation of Dynamic Systems

  • Chapter
  • First Online:
System Dynamics
  • 5647 Accesses

Abstract

An alternative to deriving a high-order differential system equation is to represent the system as a set of simultaneous first-order differential equations of the system’s state variables, which are its energy storage variables. This is known as state-space. State equations are solved numerically, using finite difference approximations. They can also be solved using Laplace transformations to yield transfer functions. State-space has three advantages. It is much easier to derive a set of state equations than the corresponding high-order differential equation. It is also easy to include non-linear properties, since the solution uses numerical methods. Finally, state-space is the basis of Modern Control theory, which enables the control designer to arbitrarily tailor the response of a system, within the physical limitations of the hardware.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 69.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 89.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info
Hardcover Book
USD 119.99
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

References and Recommended Reading

  • Ogata, K (2009) Modern control engineering, 5th edn. Prentice-Hall, Englewood Cliffs

    Google Scholar 

  • Rowell D, Wormley DN (1997) System dynamics: an introduction. Prentice-Hall, Upper Saddle River

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Karl A. Seeler .

Appendices

Summary

Linear algebra is a condensed form of the algebra of simultaneous equations where the variables are represented as vectors and the constants or coefficients are represented by matrices. The key differences between scalar and vector-matrix algebra are:

Vector-matrix multiplication is not commutative, except in the two special cases below.

$$ \mathbf{AB}\ne \mathbf{BA} $$

Scalar operators are applied to each element with a matrix. Scalar operations on a matrix are commutative.

$$ a\mathbf{B}=\mathbf{B}a $$

There is no vector-matrix division; it is not defined. The equivalent is to multiply a matrix by its inverse, which is the quantity that when multiplied by the matrix yields the identity matrix I.

$$ \mathbf{A}{{\mathbf{A}}^{-1}}={{\mathbf{A}}^{-1}}\mathbf{A}=\mathbf{I} $$

where I is the identity matrix:

$$ \mathbf{AI}=\mathbf{IA} $$

and

$$ \mathbf{I}=\left[ \begin{matrix} 1 & 0 & \ldots & 0 \\ 0 & 1 & \cdots & 0 \\ \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & 0 & 1 \\\end{matrix} \right] $$

State-space represents a dynamic system as a set of first-order simultaneous differential equations:

$$ \frac{d}{dt}\left[ \begin{matrix} {{x}_{1}} \\ {{x}_{2}} \\ \vdots \\ {{x}_{n}} \\\end{matrix} \right]=\left[ \begin{matrix} {{a}_{\,1,1}} & {{a}_{\,1,2}} & \cdots & {{a}_{\,1,n}} \\ {{a}_{\,2,1}} & {{a}_{\,2,2}} & \cdots & {{a}_{\,2,n}} \\ \vdots & \vdots & \ddots & \vdots \\ {{a}_{\,n,1}} & {{a}_{\,n,2}} & \cdots & {{a}_{\,n,n}} \\\end{matrix} \right]\left[ \begin{matrix} {{x}_{1}} \\ {{x}_{2}} \\ \vdots \\ {{x}_{n}} \\\end{matrix} \right]+\left[ \begin{matrix} {{b}_{\,1,1}} & {{b}_{\,1,2}} & \cdots & {{b}_{\,1,m}} \\ {{b}_{\,2,1}} & {{b}_{\,2,2}} & \cdots & {{b}_{\,2,m}} \\ \vdots & \vdots & \ddots & \vdots \\ {{b}_{\,n,1}} & {{b}_{\,n,2}} & \cdots & {{b}_{\,n,m}} \\\end{matrix} \right]\left[ \begin{matrix} {{u}_{\,1}}\left( t \right) \\ {{u}_{\,2}}\left( t \right) \\ \vdots \\ {{u}_{\,m}}\left( t \right) \\\end{matrix} \right] $$

Expressed in vector-matrix form as:

$$ \frac{d\,\mathbf{x}}{dt}=\mathbf{Ax}+\mathbf{Bu} $$

where x is the vector of state variables, known as the state vector, A is the coefficient matrix, B is the input matrix, and u is a vector of inputs.

The state variables used to reduce the energetic equations of a system, extracted from a schematic or a linear graph, are the energy storage variables. However, the state variables of a system are not unique since linear algebra performed on the state equations can be used to redefine the state variables as a combination of a previous set, in what is known as a transformation. State variables created by a transformation usually have no physical meaning.

The reduction of the energetic equations of a system to a set of state equations is significantly easier than the corresponding reduction to a higher-order differential equation because more variables are retained, leaving a few that must be eliminated by substitution.

The state equations are solved by finite difference methods, specifically the Runge–Kutta algorithm. The solution yields the state variable values over the duration of the solution.

The solution for a power variable other than a state variable requires a second set of purely algebraic equations called the output equations. The output equations cannot be solved until the state equations have been solved and the state vector x is known. The output equations in vector-matrix form are:

$$ \mathbf{y}=\mathbf{Cx}+\mathbf{Du} $$

where y is the vector of output variables, C is the output matrix, and D is the direct pass-through matrix.

Problems

Problems 1, 2, and 3 are to be solved “manually,” meaning, that you may use your calculator to perform arithmetic operations but not linear algebra. After you have solved the problems manually, you are encouraged to check your manual linear algebra computations using your calculator so that you become familiar with its capabilities.

Problem 7.1 Evaluate the following matrix expressions manually

$$ 7.1.\text{a}\quad \left[ \begin{matrix} 1 & 2 \\ 3 & 4 \\\end{matrix} \right]+\left[ \begin{matrix} 5 & 6 \\ 7 & 8 \\\end{matrix} \right]=\quad 7.1.\text{b}\quad 8\left[ \begin{matrix} 1 & 2 \\ 3 & 4 \\\end{matrix} \right]-\left[ \begin{matrix} 5 & 6 \\ 7 & 8 \\\end{matrix} \right]= $$

Problem 7.2 Evaluate the following matrix expressions manually

$$ 7.2.\text{a}\quad \left[ \begin{matrix} 1 & 2 \\ 3 & 4 \\\end{matrix} \right]\left[ \begin{matrix} 5 & 6 \\ 7 & 8 \\\end{matrix} \right]=\quad 7.2.\text{b}\quad \left[ \begin{matrix} 5 & 6 \\ 7 & 8 \\\end{matrix} \right]\left[ \begin{matrix} 1 & 2 \\ 3 & 4 \\\end{matrix} \right]= $$
$$ 7.2.\text{c}\quad \left[ \begin{matrix} 1 & 2 \\ 3 & 4 \\\end{matrix} \right]\left[ \begin{matrix} 5 \\ 6 \\\end{matrix} \right]=\quad 7.2.\text{d}\quad \left[ \begin{matrix} 3 & 4 \\\end{matrix} \right]\left[ \begin{matrix} 5 \\ 6 \\\end{matrix} \right]= $$
$$ 7.2.\text{e}\quad \left[ \begin{matrix} 5 \\ 6 \\\end{matrix} \right]\left[ \begin{matrix} 3 & 4 \\\end{matrix} \right]= $$

Problem 7.3 Calculate the inverses of the following matrices manually, as the transpose of the cofactors of the matrix divided by the determinant of matrix. No credit will be awarded for inverting the matrices using a graphical algorithm. Check by multiplying the matrix by its inverse manually.

$$ 7.3.\text{a}\quad {{\left[ \begin{matrix} 2 & 3 \\ 4 & 5 \\\end{matrix} \right]}^{-1}}=\quad 7.3.\text{b}\quad {{\left[ \begin{matrix} 2 & 0 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\\end{matrix} \right]}^{\,-1}}= $$

Problem 7.4 A translational mechanical system consisting of a mass M sliding on a lubricating fluid film with damping b. A spring K is attached between the mass and ground. The mass is acted upon by an applied force F(t)(Table 7.6).

Fig. P7.4
figure 17

Second order translational mechanical system

Table P7.4 Parameter values
  • 7.4.a Derive the second-order system equation for the force acting through the spring and express it in standard form.

  • 7.4.b Derive the state equations for this system.

  • 7.4.c Derive the output equations for:

    • i The velocity of the mass M.

    • ii The force acting through spring K.

    • iii The angular velocity difference across spring K.

  • 7.4.d Express the state and output equations in matrix form.

  • 7.4.e For Cases I and II, calculate the system’s eigenvalues. If the system is underdamped, determine the ideal, undamped natural frequency ω n, the damped natural frequency ω d, and the damping ratio ζ.

  • 7.4.f The system is de-energized when it is acted on by a step input of 10 N. Solve the state equations and the output equations using Mathcad or MATLAB for Cases I and II. Plot the responses of the output variables.

Problem 7. 5 A rotational mechanical system consisting of a spring, an inertia, and a damper acted upon by an applied torque is shown in the schematic Fig. P7.5.

Fig. P7.5
figure 18

Second order rotational mechanical system

Table P7.5 Parameter values
  • 7.5.a Derive the second-order system equation for the torque in the spring and express it in the standard form.

  • 7.5.b Derive the state equations for this system.

  • 7.5.c Derive the output equations for:

    • i The angular velocity of the inertia J.

    • ii The torque acting through the compliant shaft spring K.

    • iii The angular velocity difference across the compliant shaft spring K.

    • iv The angular velocity difference across the fluid coupling b.

  • 7.5.d Express the state and output equations in matrix form.

  • 7.5.e For Cases I and II, calculate the system’s eigenvalues. If the system is underdamped, determine the ideal, undamped natural frequency ω n , the damped natural frequency ω d, and the damping ratio ζ

  • 7.5.f The system is de-energized when it is acted on by a step input of 10 rad/sec. Solve the state equations and the output equations using Mathcad or MATLAB for Cases I and II. Plot the responses of the output variables.

Problem 7. 6 A translational mechanical system consisting of a spring, two masses, and two dampers acted upon by an applied force is shown in the schematic Fig. P7.6.

Fig. P7.6
figure 19

Third-order mechanical system

Table P7.6 Parameter values
  • 7.6.a Derive the state equations for this system.

  • 7.6.b Derive the output equations

    • i The velocity of mass M 1 .

    • ii The force acting through the spring K.

    • iii The velocity of mass M 2 .

    • iv The force acting through damper b 1.

    • v The force acting through damper b 2.

  • 7.6.c Express the state and output equations in matrix form.

  • 7.6.d Calculate the system’s eigenvalues for Cases I and II. If the system is underdamped, determine the ideal, undamped natural frequency ω n , the damped natural frequency ω d, and the damping ratio ζ.

  • 7.6.e The system was de-energized when a step input of 10 was applied. For Cases I and II, solve the state equations and the output equations using Mathcad or MATLAB. Plot the responses of the output variables.

Problem 7. 7 A fluid system consisting of a fluid power unit modeled as a pressure source, three fluid resistances, a fluid accumulator with capacitance C, a fluid inertance I, and a hydraulic piston/cylinder driving a mass M is shown is shown in the schematic, Fig. P7.7. Note that the mass and the fluid inertance are dependent energy storage elements.

Fig. P7.7
figure 20

Hybrid fluid-translational mechanical system

Table P7.7 Parameter values
  • 7.7.a Derive the state equations for this system and check their units

  • 7.7.b Derive output equations for:

    • i The pressure in the fluid accumulator.

    • ii The velocity of mass M.

    • iii The volume flow rate through the fluid inertance.

    • iv The volume flow rate from the pressure source.

    • v The force acting to accelerate mass M.

    • vi The pressure drop across the fluid inertance.

  • 7.7.c Express the state and output equations in matrix form.

  • 7.7.d Calculate the system’s eigenvalues. If the system is underdamped, determine the ideal, undamped natural frequency ω n , the damped natural frequency ω d, and the damping ratio ζ.

  • 7.7.e The system was de-energized when a step input of 100 was applied. Solve the state equations and the output equations using Mathcad or MATLAB. Plot the responses of the output variables.

Problem 7.8 A hybrid fluid-translational rotational system is shown in Fig. P7.8. The fluid power unit is modeled as a pressure source, which discharges into a hydraulic line with fluid resistance R. The hydraulic piston/cylinder has diameter D. Its piston rod is attached to the linkage. A dashpot with damping b and a spring K are also attached to the linkage. The linkage has rotational inertia J.

Fig. P7.8
figure 21

Fluid-translational mechanical system

Table P7.8 Parameter values
  • 7.8.a Derive the state equations for this system and check their units.

  • 7.8.b Derive output equations for:

    • i The volume flow rate from the source.

    • ii The force applied by the piston rod.

    • iii The force in spring K.

    • iv The angular velocity of the linkage.

    • v The velocity difference across the spring.

  • 7.8.c Express the state and output equations in matrix form.

  • 7.8.d Calculate the system’s eigenvalues. If the system is underdamped, determine the ideal, undamped natural frequency ω n , the damped natural frequency ω d, and the damping ratio ζ.

  • 7.8.e The system was de-energized when a step input of 2,000 was applied. Solve the state equations and the output equations using Mathcad or MATLAB. Plot the responses of the output variables.

Problem 7. 9 A translational mechanical system is shown schematically in Fig. P7.9. The system consists of a force source F(t) acting on a lever, to which are attached a damper b 1 and two springs, K 1 and K 2. Spring K 2 is attached to mass M, which slides on a rail with a lubricating film, damping b 2. The system is de-energized before the input step force of 1,000 N acts on the system.

Fig. P7.9
figure 22

Translational mechanical system

Table P7.9 Parameter values
  • 7.9.a Derive the state equations for this system and check their units.

  • 7.9.b Derive output equations for:

    • i The force acting to accelerate mass M.

    • ii The velocity of mass M.

    • iii The force acting through spring K 1.

    • iv The force acting through spring K 2.

    • v The velocity of the point of application of the input force F(t).

  • 7.9.c Express the state and output equations in matrix form.

  • 7.9.d Calculate the system’s eigenvalues. If the system is underdamped, determine the ideal, undamped natural frequency ω n , the damped natural frequency ω d, and the damping ratio ζ.

  • 7.9.e Solve the state equations and the output equations using Mathcad or MATLAB. Plot the responses of the output variables.

Problem 7.10 An electromechanical system is shown in Fig. P7.10. The input to the system is a voltage which drives a DC motor through wires with electrical resistance R. The relationship between the motor’s current and torque is T M  = αi M . Flywheel J 1 is attached to the motor’s shaft and is supported by bearings with damping b 1. Coupled to the motor’s shaft is a compliant shaft modeled as torsion spring K. The compliant shaft drives flywheel J 2,which is supported by bearings with damping b 2.

Fig. P7.10
figure 23

Hybrid electromechanical system

Table P7.10 Parameter values
  • 7.10.a Derive the state equations for this system and check their units.

  • 7.10.b Derive output equations for:

    • i The current from the source.

    • ii The torque acting to accelerate angular velocity of rotational inertia J 1.

    • iii The angular velocity of rotational inertia J 1.

    • iv The angular velocity of rotational inertia J 2.

    • v The torque acting through spring K.

  • 7.10.c Express the state and output equations in matrix form.

  • 7.10.d Calculate the system’s eigenvalues. If the system is underdamped, determine the ideal, undamped natural frequency ω n , the damped natural frequency ω d, and the damping ratio ζ.

  • 7.10.e The system was de-energized before a step input of 48 VDC was applied. Solve the state equations and the output equations using Mathcad or MATLAB. Plot the responses of the output variables.

Problem 7. 11 A rotational system show is shown in Fig. 7.11. An angular velocity source drives the shaft attached to the pulley with diameter D 1. The belt over pulley D 1 drives the pulley with diameter D 2, which is attached to the same shaft as the pulley with diameter D 3. That shaft is compliant, with spring constant K, and drives the flywheel with rotational inertia J 1 and damping b 1. The belt over pulley D 3 drives the pulley with diameter D 4, which is attached to a shaft connect to the fluid coupling with damping b 2. The output shaft of the fluid coupling drives the flywheel with rotational inertia J 2 and damping b 1.

Fig. P.7.11
figure 24

Rotational system

Table P7.11a Parameter Values
Table 7.11b Torsion spring stiffness K values
  • 7.11.a Derive the state equations for this system and check their units.

  • 7.11.b Derive output equations for:

    • i The torque acting through spring K .

    • ii The angular velocity of flywheel J 1.

    • iii The torque applied by the angular velocity source.

    • iv The torque acting to accelerate flywheel J 2.

    • v The angular velocity of flywheel J 2.

  • 7.11.c Express the state and output equations in matrix form.

  • 7.11.d Calculate the system’s eigenvalues for Cases I, II, and III using the damping coefficient values of Table 7.11b. If the system is underdamped, determine the ideal, undamped natural frequency ω n , the damped natural frequency ωd, and the damping ratio ζ.

  • 7.11.e The system was de-energized before a step input of 1,500 RPM was applied. Solve the state equations using Mathcad or MATLAB.

  • 7.11.f Solve and plot the responses of the output variables using Mathcad or MATLAB.

Problem 7. 12 A rotational mechanical system is shown schematically in Fig. P7.12. The system consists of an angular velocity source Ω(t) acting on the input shaft of a fluid coupling with damping b 1. The output shaft of the fluid coupling drives inertia J 1, which drives a compliant shaft with torsional spring constant K. The compliant shaft drives a pinion with N 1 teeth. The pinion engages a gear with N 2 teeth. The gear shaft drives rotational inertia J 2. The gear shaft bearings have damping b 2.

Fig. P7.12a
figure 25

A shaft-driven rotational system with a compound gear

Table 7.12a Parameter values
Table 7.12b Fluid coupling damping b 1 values
Table 7.12c Gear Teeth Numbers
  • 7.12.a Derive the state equations and check their units.

  • 7.12.b Derive output equations for the following variables:

    • i The angular velocity of the pinion.

    • ii The torque acting through the compliant shaft.

    • iii The torque acting to accelerate inertia J 2.

    • iv The torque acting through the fluid coupling b 1.

  • 7.12. c Write the state equations and output equations in vector-matrix form.

  • 7.12.d Calculate the system’s eigenvalues for Cases I, II, and III. If the system is underdamped, determine the ideal, undamped natural frequency ω n , the damped natural frequency ωd, and the damping ratio ζ.

The system is de-energized before the input pulse of angular velocity shown in Fig. 7.12b is applied.

Fig. P7.12b
figure 26

Angular velocity input

  • 7.12.e Solve and plot state equations for the velocity pulse shown in Fig. P7.12b.

  • 7.12.f Solve and plot the output equations.

Problem 7. 13 A rotational-translational mechanical system is shown schematically in Fig. P7.13. The system consists of a torque source acting on the input shaft of a pinion with N 1 teeth. The pinion engages a gear with N 2 teeth and rotational inertia J. The gear drives a compliant shaft modeled as a torsional spring with spring constant K. The shaft turns a power screw with a linear pitch of n threads per inch. The power screw threads through the crosshead. The crosshead translates when the power screw rotates. The viscous friction between the rotating power screw and the translating crosshead is modeled as rotational damping b 1. The crosshead has mass M and slides on two rails. The combined viscous friction of the crosshead sliding on the two rails is modeled as translational damping b 2.

Fig. P7.13
figure 27

A hybrid rotational-translational system

Table 7.13 Parameter values
  • 7.13.a Derive the state equations and check their units.

  • 7.13.b Derive output equations for the following variables:

    • i The angular velocity of the pinion shaft.

    • ii The angular velocity gear N 2.

    • iii The torque in the compliant shaft.

    • iv The force acting to accelerate the crosshead.

    • v The translational velocity of the crosshead.

  • 7.13. c Write the state equations and output equations in vector-matrix form.

  • 7.13.d Calculate the system’s eigenvalues. If the system is underdamped, determine the ideal, undamped natural frequency ω n , the damped natural frequency ωd, and the damping ratio ζ.

Fig. P7.13b
figure 28

Torque input

The system is de-energized before the input torque pulse shown in Fig. P7.13b was applied to the system.

  • 7.13.e Solve the state equations using Mathcad or MATLAB for the input torque pulse shown in Fig. P7.13b with the parameter values of Table 7.

  • 7.13.f Solve and plot the responses of the output variables using Mathcad or MATLAB.

Problem 7. 14 A fluid-rotational mechanical system is shown in Fig. P7.14. The fluid power unit is modeled as pressure source p(t), drawing fluid from a reservoir vented to the atmosphere. The pump’s high-pressure line has fluid resistance R and inertance I. The rotational hydraulic motor produces 600 ft.-lbs. of torque at a hydraulic fluid pressure of 3,000 psi. The fluid discharging from the motor returns to the reservoir. The output shaft of the motor turns a compliant shaft with torsion spring constant K. The compliant shaft drives a flywheel with mass moment of inertia J supported on bearings with damping b.

Table 7.14 Parameter values
  • 7.14.a Derive the state equations and check their units.

  • 7.14.b Derive output equations for the following variables:

    • i The volume flow rate from the fluid power unit.

    • ii The pressure in the fluid accumulator.

    • iii The angular velocity of the hydraulic motor.

    • iv The torque acting to accelerate the flywheel.

    • v The angular velocity of the flywheel.

Fig. P7.14
figure 29

Hybrid fluid-rotational mechanical system

  • 7.14.c Write the state equations and output equations in vector-matrix form.

  • 7.14.d Calculate the system’s eigenvalues. If the system is underdamped, determine the ideal, undamped natural frequency ω n , the damped natural frequency ωd, and the damping ratio ζ. If the real components of the eigenvalues vary by two or more orders of magnitude, then the duration of the components of the response vary by like magnitude. If so, solve the state equations twice, once using a short duration to see the fast response.

Fig. P7.14b
figure 30

Pressure input

The system is running in steady state at the input pressure of 1,500 psi before the input torque pulse shown in Fig. P7.13b was applied to the system at time t = 0.

  • 7.14.e Solve the state equations using Mathcad or MATLAB for the input pressure pulse shown in Fig. P7.13b with the parameter values of Table 7.14.

  • 7.14.f Plot the responses of the output variables using Mathcad or MATLAB.

Problem 7. 15 A rotational system is shown in Fig. 7.15. An angular velocity source drives the input shaft to a fluid coupling with damping b 1. The output shaft of the fluid coupling drives shaft is compliant, with spring constant K 1, which drives a flywheel J 1 with rotational inertia J 1. A compliant shaft with spring constant K 2 , from flywheel J 1 drives flywheel J 2 with rotational inertia J 2. A drag cup with damping b 2 is connected between the hub of flywheel J 2 and the machine frame, which is ground.

Fig. P7.15
figure 31

A rotational mechanical system

Table 7.15a Parameter values
Table 7.15b Fluid coupling damping b 1 values
  • 7.15.a Derive the state equations and check their units.

  • 7.15.b Derive output equations for the following variables:

    • i The angular velocity of the pinion.

    • ii The torque acting through the compliant shaft.

    • iii The torque acting to accelerate inertia J 2.

    • iv The torque acting through the fluid coupling b 1.

  • 7.15. c Write the state equations and output equations in vector-matrix form.

  • 7.15.d Calculate the system’s eigenvalues for Cases I, II, and III. If the system is underdamped, determine the ideal, undamped natural frequency ω n , the damped natural frequency ω d, and the damping ratio ζ.

  • 7.15.e The system was de-energized before a step input of 1,500 RPM was applied. Solve the state equations and plot their responses using Mathcad or MATLAB for cases I, II, and III.

  • 7.15.f Solve and plot the responses of the output variables using Mathcad or MATLAB for cases I, II, and III.

  • 7.15.g Calculate and plot the power dissipated in the fluid coupling b 1 and the drag cup b 2 for cases I, II, and III.

Problem 7.16 The schematic of an electric circuit with a voltage source, two inductors, two capacitors and a resistor is shown in Fig. P7.16.

Fig. P7.16
figure 32

An RLC circuit

Table 7.16a Parameter values
Table 7.16b Resistor R values
  • 7.16.a Derive the state equations and check their units.

  • 7.16.b Derive output equations for the following variables:

    • i The current flowing through capacitor C 1.

    • ii The current flowing through capacitor C 2.

    • iii The voltage across inductor L 1.

    • iv The current through resistor R.

  • 7.16. c Write the state equations and output equations in vector-matrix form.

  • 7.16.d Calculate the system’s eigenvalues for Cases I, II, and III. If the system is underdamped, determine the ideal, undamped natural frequency ω n , the damped natural frequency ω d, and the damping ratio ζ.

  • 7.16.e The system was de-energized before a step input of 24 VDC was applied. Solve the state equations and plot their responses using Mathcad or MATLAB for cases I, II, and III.

  • 7.16.f Solve and plot the responses of the output variables using Mathcad or MATLAB for cases I, II, and III.

  • 7.16.g Calculate and plot the power dissipated in resistor R for cases I, II, and III.

Problem 7.17 The schematic of an electric circuit with a voltage source, two inductors, two capacitors and a resistor is shown in Fig. P7.17.

Fig. P7.17
figure 33

An RLC circuit

Table 7.17a Parameter values
Table 7.17b Resistor R values
  • 7.17.a Derive the state equations and check their units.

  • 7.17.b Derive output equations for the following variables:

    • i The current flowing through capacitor C 1.

    • ii The current flowing through capacitor C 2.

    • iii The voltage across inductor L 1.

    • iv The current through resistor R.

  • 7.17. c Write the state equations and output equations in vector-matrix form.

  • 7.17.d Calculate the system’s eigenvalues for Cases I, II, and III. If the system is underdamped, determine the ideal, undamped natural frequency ω n , the damped natural frequency ω d, and the damping ratio ζ.

  • 7.17.e The system was de-energized before a step input of 24 VDC was applied. Solve the state equations and plot their responses using Mathcad or MATLAB for cases I, II, and III.

  • 7.17.f Solve and plot the responses of the output variables using Mathcad or MATLAB for cases I, II, and III.

  • 7.17.g Calculate and plot the power dissipated in resistor R for cases I, II, and III.

Problem 7.18 An electromechanical system is shown in Fig. P7.18a. A voltage source drives a DC motor, which has resistance R and torque constant K T . The DC motor turns a compliant shaft, modeled as a torsion spring with spring constant K 1.

The shaft turns flywheel1 with mass-moment of inertia J 1. Flywheel1 is supported on bearings with damping b 1. Flywheel2 has mass-moment of inertia J 2 bearings with damping b 2, and is belt driven. The belt which runs between flywheels one and two is long enough that the energy stored in the taut or stretched side of the belt, Fig. P7.18b, must be included in the dynamic system. The compliant belt is represented by a translational spring between two transducers, which interface between the torque on the pulley’s shafts and the force carried by the belt, Fig. P7.18c. The sign reversal in the translational spring represents the taut and slack sides of the belt’s switching positions.

Fig. P7.18a
figure 34

Electromechanical system with a compliant shaft and a compliant belt

Fig. P7.18b
figure 35

The compliant belt’s taut and slack sides switch positions during an oscillation

Fig. P7.18c
figure 36

Linear graph representing a compliant belt as a translational spring between two rotational to translational transducer interfaces

Table 7.18 Parameter values
  • 7.18.a Derive the state equations and check their units.

  • 7.18.b Derive output equations for the following variables:

    • i The current drawn from the voltage source.

    • ii The back-EMF of the DC motor.

    • iii The torque acting to accelerate flywheel J 1.

    • iv The torque acting to accelerate flywheel J 2.

  • 7.18. c Write the state equations and output equations in vector-matrix form.

  • 7.18.d Calculate the system’s eigenvalues. If the system is underdamped, determine the ideal, undamped natural frequency ω n , the damped natural frequency ω d, and the damping ratio ζ.

  • 7.18.e The system was de-energized before a step input of 48 VDC was applied. Solve the state equations and plot their responses using Mathcad or MATLAB. 7.18.f Solve and plot the responses of the output variables using Mathcad or MATLAB.

Problem 7.19 A hybrid rotational-translational mechanical system is shown schematically in Fig. P7.16. The system consists of a force source F(t) acting on a lever, to which are attached a damper b 1 and two springs, K 1 and K 2. The lever has mass moment of inertia J. Spring K 2 is attached to mass M, which slides on a rail with a lubricating film, damping b 2. The system is de-energized before the input step force of 1,000 N acts on the system.

Fig. P7.19
figure 37

Hybrid rotational-translational mechanical system

Table P7.19 Parameter Values
  • 7.19.a Derive the state equations for this system and check their units.

  • 7.19.b Derive output equations for

    • i The force acting to accelerate mass M.

    • ii The velocity of mass M.

    • iii The force acting through spring K 1.

    • iv The force acting through spring K 2.

    • v The angular velocity of the lever.

    • vi The velocity of the point of application of the input force F(t).

  • 7.19.c Express the state and output equations in matrix form.

  • 7.19.d Calculate the system’s eigenvalues. If the system is underdamped, determine the ideal, undamped natural frequency ω n , the damped natural frequency ω d, and the damping ratio ζ.

  • 7.19.e Solve the state equations and the output equations using Mathcad or MATLAB.

  • 7.19.f Plot the responses of the output variables using Mathcad or MATLAB.

Problem 7.20 The stainless steel and aluminum thermal system of Sect. 5.8.4 is reproduced as Fig. 5.52. The stainless steel is 0.5 in. thick. The aluminum is 2 in. thick. Both metals are divided into layers 0.25 in. thick, parallel to the external surfaces. The thermal system model consists of thermal resistances in series and thermal capacitances in parallel. The linear graph is Fig. 5.53. The thermal resistances of the stainless steel and aluminum are calculated for 0.25 in. layer. The thermal capacitances are calculated pairing adjacent layers and using the temperature node between them as the temperature of the 0.5 in. thick capacitance.

Fig. 5.52
figure 38

Thermal system divides into five regions, each with a thermal capacitance between the center temperature node of the region and ground temperature

Fig. 53
figure 39

Linear graph of the stainless steel and aluminum thermal system. The linear graph is split between nodes 6 and 7 for this figure

The thermal resistances of the 0.25 in. thick stainless steel and aluminum layers are:

\({R_{SS}} = 8.23 \times {10^{ - 5}}\frac{{{}^{\rm{o}}{\rm{K}}}}{{\rm{W}}}\) and \({R_{Al}} = 6.91 \times {10^{ - 6}}\frac{{{}^{\rm{o}}{\rm{K}}}}{{\rm{W}}}\)

The thermal capacitances of the stainless steel and aluminum are:

\( {C_{{p_{SS}}}} = 204\,\,\frac{{{\rm{kJ}}}}{{^{\rm{o}}{\rm{K}}}} \) and \( {C_{{p_{Al}}}} = 137\,\,\frac{{{\rm{kJ}}}}{{^{\rm{o}}{\rm{K}}}} \)

  • 7.20.a Derive the state equations for this system and check their units.

  • 7.20.b Derive output equations for:

    • i The temperatures of nodes 2, 4, 6, 8, and 10.

    • ii The heat flow rate through thermal resistances

\( {R_{S{S_1}}} \), \( {R_{a{l_1}}} \), \( {R_{a{l_3}}} \), \( {R_{a{l_5}}} \), \( {R_{a{l_{\,7}}}} \), \( {R_{a{l_9}}} \), and \( {R_{a{l_{10}}}} \).

  • 7.20.c Express the state and output equations in matrix form.

  • 7.20.d Calculate the system’s eigenvalues.

The thermal system is at the uniform temperature of 20 °C when the temperature of node 1 is given a step increase to 100 °C. The temperature of node 11 is held at 20 °C.

  • 7.20.e Solve the state equations and the output equations using Mathcad or MATLAB.

  • 7.20.f Plot the responses of the output variables using Mathcad or MATLAB.

Chapter 7 Appendix

7.3.1 Mathcad’s Runge–Kutta Solver

Mathcad has two versions of the Runge–Kutta algorithm, rkfixed(), which has a constant, or fixed, time step Δt and Rkadapt(). Rkadapt() adapts or varies the time step, reducing its size if the finite differences become large and increasing it when they are small. We will use rkfixed(). Rkadapt() is used when a calculation is numerically stable only with an excessive number of time steps.

The Runge–Kutta solver rkfixed() is a function. It is used in an assignment statement where the result of the Runge–Kutta calculation is assigned to a variable, say Z. The Mathcad syntax is:

$$ Z\,\,:=\,\,rkfixed(a,b,c,d,e) $$

where

  • a is the state variable vector.

  • b is the beginning time of the simulation.

  • c is the end time of the simulation.

  • d is the number of time intervals in the simulation.

  • e is the vector containing the state equations.

The time step Δt = (c-b)/d.

The function rkfixed() returns an array, Z in this example. The first column of the array is time. The succeeding columns are the values of the state variables at those times, i.e., the second column is the first state variable, the third column is the second state variable, etc. A column of a matrix can be extracted using a special operator. Typing Ctrl and 6 simultaneously immediately following a matrix variable produces a pair of exponentiated angle brackets. The column number to be extracted is inserted into the angle brackets. Remember that Mathcad’s “origin,” the beginning value of indices, is zero, unless it is changed by the user. Hence, the first column of a matrix is column zero. The following command assigns the first column of the array Z to the variable t.

$$ t:={{Z}^{\left\langle 0 \right\rangle }} $$

The Runge–Kutta method will fail when simulating second-order or higher systems if the time step is too large. The calculation will become “numerically unstable” and produce a result with growing oscillations that head to either positive or negative infinity. Errors formulating the state equations, particularly sign errors, can also lead to numerical instability. The physical systems which are not under feedback control are physically stable. Therefore, if the calculation is unstable reduce the time step by an order of magnitude or two. If the calculation is still numerically unstable, then check your state equations.

The procedure will be illustrated with a first-order mass-damper system. The first-order system will also be used to demonstrate the response of the system to inputs other than step inputs. Next, the response of a second-order spring-mass-damper system will be investigated.

7.3.2 Step Response of a Linear Mass-Damper System

Figure 3.13 showing the schematic and linear graph of a force source sliding a mass on a lubricating film and the system equation for the velocity of the mass, Eq. 3.26, are reproduced here for reference.

$$ \frac{{F(t)}}{b} = \frac{M}{b}\frac{{d{v_{1g}}}}{{dt}} + {v_{1g}}\quad \, \to \quad \frac{{F(t)}}{M} = \frac{{d{v_{1g}}}}{{dt}} - \frac{b}{M}{v_{1g}} $$
(3.26)

Standard form of a first-order system equation requires little rearrangement to form into a state equation.

$$ \frac{{F( t )}}{M} = \frac{{d{v_{1g}}}}{{dt}} + \frac{b}{M}{v_{1g}}\,\,\,\,\,\, \to \,\,\,\,\,\,\frac{{d{v_{1g}}}}{{dt}} =- \frac{b}{M}{v_{1g}} + \frac{{F( t )}}{M} $$

The Mathcad code begins by defining the input function, parameter values, and the initial value of the state variable. We will first solve the state equation for a step input with the system initially de-energized using the following parameters:

$$ M: = 3\,\,\,\,\,\,\,\,\,\,\,\,b: = 2\,\,\,\,\,\,\,\,\,\,\,\,F: = 10 $$
Fig. 3.13
figure 40

a Translational mechanical mass-damper system driven by a force source, b Linear graph of the mass-damper system driven by a force source

Define a state variable vector by assigning the initial value to each state variable. Here, the mathematical meaning of “vector” collides with the computer science meaning. Each individual state variable must be a computer science vector to contain the value of the variable at each time step in the calculation. Recall that the period indicates a “literal” subscript that Mathcad accepts as part of the variable name [indicates what follows to be a vector or matrix subscript].

$$ Type\,\,x[0\,\,\,\,\,\,to\,\,see\,\,\,\,\,\,{{x}_{0}} $$

Mathcad recognizes x as a vector variable because it has vector a subscript. Define the initial value of the state variable x to be zero.

$$ {{x}_{0}}:=0 $$

The state equation must be defined as a function to two variables. The first argument, t, is the independent variable. The second argument is the name of the state vector. We have a single state variable, not a state variable, so we identify the state variable. One can name the function which defines the state equations. We will use D(t, x).

$$ D\left( t,x \right):=\frac{-b}{M}\cdot x+\frac{F}{M} $$

In general, the function D(t, x) contains a vector of the state equations. In this case, there is only one equation. Notice that the independent variable t does not need to appear on the right side of the assignment statement. It can be used, as demonstrated below.

First-order system difference equations cannot be numerically unstable. We will use a large number of steps, say 1,000, which is far more than is needed for accuracy.

The rkfixed function assigning its result to Z is:

$$ Z:=rkfixed(x,0,10,1000,D) $$

The arguments of rkfixed() are:

x = :

vector of state variables.

0 = :

start time

10 = :

end time

100 = :

number of increments

D = :

vector of state equations.

Fig. A7.1
figure 41

Step response of a linear mass-damper system

We can plot the columns of the array Z directly, but this leads to errors because it is easy to forget which state variable is when there is more than one. It is best to copy the columns of the array to vectors.

$$ t1:={{Z}^{\left\langle 0 \right\rangle}}\,\,\,\,\,\,\,\,\,\,\,\,{{v}_{1g}}:={{Z}^{\left\langle 1\right\rangle }} $$

The subscripts 1 g are literal subscripts produced by typing a period after “v,” v.1 g

This procedure hardly saves time when solving a linear first-order equation subjected to a step input, since there are only four possible solutions. Fortunately, we can use the same procedure to solve some nonlinear equations and all linear equations subjected to arbitrary inputs.

First, let’s compare the above response for a mass-damper with linear damping \( {F_b} = b{v_{1g}} \)with the response of a system with non-linear damping \( {F_{{b_{NL}}}} = bv_{1g}^2 \)

7.3.3 Step Response of a Mass-Damper System with a Non-Linear Damper

The Mathcad code is identical, except the state equation. We will again define the parameter values, the magnitude of the input force, and the initial value of the state variable so that the code is complete. There is no need to repeat these Mathcad statements if they are unchanged.

$$ M: = 3\,\,\,\,\,\,\,\,\,\,\,\,b: = 2\,\,\,\,\,\,\,\,\,\,\,\,F: = 10 $$

Define the initial value of the state variable to be zero.

$$ {{x}_{0}}:=0 $$

Define the state equation. Note that the state variable is squared.

$$ D\left( t,x \right):=\frac{-b}{M}\cdot {{x}^{2}}+\frac{F}{M} $$

Assign the result of the Runge–Kutta function to the variable ZNL, where the subscript NL is a literal subscript.

$$ {{Z}_{NL}}:=rkfixed(x,0,10,1000,D) $$

It is best to copy the columns of the matrix \( {Z_{NL}} \) to vectors. We could use the same name for the time vector since they are identical. We will create a new time vector.

$$ t2:={{Z}_{NL}}^{\left\langle 0 \right\rangle}\,\,\,\,\,\,\,\,\,\,\,\,{{v}_{NL}}:={{Z}_{NL}}^{\left\langle 1\right\rangle } $$

7.3.4 Response of a Linear Mass-Damper System Subjected to a Pulse Train

D(t, x) is a function of t, allowing the input functions of the state equations to functions of time. Example: F pulses (t) is a pulse train made of step functions.

$$ F(t): = 5 \cdot \Phi (t) - 10 \cdot \Phi (t - 2) + 5 \cdot \Phi (t - 4) $$

The remaining Mathcad code is unchanged except that the input force in the state equations is now a function of time.

$$ M: = 3\,\,\,\,\,\,\,\,\,\,\,\,b: = 2 $$
$$ {{x}_{0}}:=0 $$
Fig. A7.2
figure 42

Step response of a linear mass-damper system, solid trace, and a non-linear mass-damper system, dotted trace

$$ D\left( t,x \right):=\frac{-b}{M}\cdot x+\frac{1}{M}F(t) $$

Assign the result of the Runge–Kutta function to the variable Zpulses.

$$ {{Z}_{pulses}}:=rkfixed(x,0,10,1000,D) $$

Copy the columns of the result to vectors.

$$ t3:={{Z}_{pulses}}^{\left\langle 0 \right\rangle }\,\,\,\,\,\,\,\,\,\,\,\,{{v}_{pulses}}:={{Z}_{pulses}}^{\left\langle 1 \right\rangle } $$

In order to plot the input pulse function, we define a range variable, q, of the same length as the time vector t3. The variable q must start at zero, so we must subtract one from the length of the vector t3.

$$ q:=0..length(t3)-1 $$

The pulse input is plotted on the secondary y-axis using the range variable as the vector subscript for the time vector, Fig. A7.3.

7.3.5 Response of a Mass-Damper System to Sinusoidal Inputs

Calculation of the response of the first-order mass-damper system to sinusoidal inputs is a second example of the use of the independent variable t to define a function of time as the input to the state equations.

We will again define values even though they have been previously defined and are unchanged so the each block of Mathcad code is complete.

Fig. A7.3
figure 43

Pulse response of a linear mass-damper system, solid trace, and the pulse input, dotted trace

$$ M: = 3\,\,\,\,\,\,\,\,\,\,\,\,b: = 2 $$
$$ {{x}_{0}}:=0 $$
$$ D\left( t,x \right):=\frac{-b}{M}\cdot x+\frac{1}{M}\sin (\pi \cdot t) $$
$$ {{Z}_{pi}}:=rkfixed(x,0,10,1000,D) $$
$$ t4:={{Z}_{pi}}^{\left\langle 0 \right\rangle }\,\,\,\,\,\,\,\,\,\,\,\,{{v}_{pi}}:={{Z}_{pi}}^{\left\langle 1 \right\rangle } $$

Second block of code:

$$ \begin{array}{*{20}{c}}{M: = 3\,\,\,\,\,\,\,\,\,\,\,\,b: = 2}\\{{x_0}: = 0}\\{D( {t,x} ): = \frac{{ - b}}{M} \cdot x + \frac{1}{M}\sin (4 \cdot \pi\cdot t)}\\{{Z_{4pi}}: = rkfixed(x,0,10,1000,D)}\\{t4: = {Z_{4pi}}^{\left\langle 0 \right\rangle }\,\,\,\,\,\,\,\,\,\,\,\,{v_{4pi}}: = {Z_{4pi}}^{\left\langle 1 \right\rangle }}\end{array} $$
Fig. A7.4
figure 44

Sinusoidal responses of the first-order mass-damper system. Solid trace input frequency ω = 2π. Dashed trace, input frequency ω = 4π

7.3.6 Step Response of a Spring-Mass-Damper System

The Mathcad code to solve higher-order state space systems has an additional assignment statement to create a vector of the state variables. We will illustrate the calculation using the spring-mass-damper system, Fig. A7.5.

The first Mathcad instructions are identical to those of the first order mass-damper system, except that there is now a spring constant K.

$$ M: = 3\,\,\,\,\,\,\,\,\,\,\,\,b: = 0.2\,\,\,\,\,\,\,\,\,\,\,\,K: = 1\,\,\,\,\,\,\,\,\,\,\,\,F: = 10 $$

Assume that the system is at rest and relaxed. Define a vector of the initial conditions of the state variables. It is essential that the state variables are identified in the Mathcad worksheet. A common error is to not identify which state variable is which and then forget and use the wrong state variable in a subsequent calculation. The state variables can be identified in text as a comment, such as x1 = v1g and x2 = FK, and then the initial values of the state variables defined as

$$ x{{1}_{0}}:=0\,\,\,\,\,\,\,\,\,\,\,\,x{{2}_{0}}:=0 $$

where the subscripts are vector subscripts created by typing.

The state vector is then defined as:

$$ x:=\left( \begin{matrix} x{{1}_{0}} \\ x{{2}_{0}} \\\end{matrix} \right) $$
Fig. A7. 5
figure 45

a force source-spring-mass-damper system, b Linear graph of the force source-spring-mass-damper system

This syntax is very specific. The state vector x cannot have a vector subscript. The state variables x1 and x2 must have the vector subscript zero.

The alternative is to give the individual state variables meaningful names:

$$ \text{v1}{{\text{g}}_{0}}:=0\,\,\,\,\,\,\,\,\,\,\,\,\text{F}{{\text{K}}_{0}}:=0\,\,\,\,\,\,\,\,\,\,\,\,\text{or}\,\,\,\,\,\,\,\,\,\,\,\,{{\text{v}}_{\text{1g}}}_{_{0}}:=0\,\,\,\,\,\,\,\,\,\,\,\,\text{F}{{\text{K}}_{0}}:=0 $$

where the latter have literal subscripts for 1 g and K and vector subscripts for zero.

The state vector x is the vector of the initial values of the state variables where, again, the state vector x cannot have a vector subscript and the state variables \( {v_{1g}} \)and \( {F_K} \) must have the vector subscript of zero.

$$ x: = \left( {\begin{array}{*{20}{c}}{{{\text{v}}_{1{g_0}}}}\\{{{\text{F}}_{{{\text{K}}_0}}}}\end{array}} \right)$$

The state equations are:

$${\text{D}}({\text{t,}}\;{\text{x}}):\; = \left({\begin{array}{*{20}{c}}{\frac{{ - b}}{M}}&{\frac{1}{M}} \\ K&0\end{array}} \right) \cdot {\text{x}} + \left( {\begin{array}{*{20}{c}}{\frac{1}{M}} \\ 0\end{array}} \right)\cdot{\text{F}}$$

Finite difference computations of higher-order systems can go unstable if the time step Δt is too large. As a rule of thumb, if the eigenvalues of complex conjugates, 200 steps per period of the (of the smallest period in the system if four order) is sufficient for a stable and accurate calculation. If the plots of the state equations blow up (head off to positive or negative infinity) or if Mathcad indicates an error in the rkfixed() function, either decrease the duration of the calculation, or increase the number of calculations, to decrease the time step. If the calculation is still “numerically unstable,” check for a sign error in the Mathcad code or the reduction of the state equations. A single sign error is sufficient to create a numerical instability.

We will increase to duration of the calculation to 25 sec and the number of calculations to 2,000 for the rkfixed() solver function.

$$ {{Z}_{MbK}}:rkfixed(x,0,25,2000,D) $$

Extract the time and state variable vectors (in the computer science meaning) from the array ZMbK.

Fig. A7.6
figure 46

Response of the state variable v1g and FK to a step input 10 N

$$ {{t}_{MbK}}:={{Z}_{MbK}}^{\left\langle 0 \right\rangle}\,\,\,\,\,\,\,\,\,\,\,\,{{v}_{1g}}:={{Z}_{MbK}}^{\left\langle 1\right\rangle}\,\,\,\,\,\,\,\,\,\,\,\,{{F}_{K}}:={{Z}_{MbK}}^{\left\langle 2\right\rangle } $$

The output variables are calculated using values of the state variables from the solution of the state equations. Often, the state variables are included as output variables, as below.

$$ \left( \begin{matrix} {{v}_{1g}} \\ {{F}_{K}} \\ {{F}_{M}} \\ {{F}_{b}} \\\end{matrix} \right):=\left( \begin{matrix} 1 & 0 \\ 0 & 1 \\ -b & -1 \\ b & 0 \\\end{matrix} \right)\cdot \left( \begin{matrix} {{v}_{1g}} \\ {{F}_{K}} \\\end{matrix} \right)+\left( \begin{matrix} 0 \\ 0 \\ 1 \\ 0 \\\end{matrix} \right)\cdot F $$
Fig. A7.7
figure 47

Response of output variables v1g, FK, FM and Fb to a step input of 10 N

MATLAB’s Runge–Kutta Solver ode45()

MATLAB’s general purpose Runge–Kutta solver function is named ode45(). If it helps you remember the name, the 45 stands for “fourth-order” overall error, “fifth-order” local error.

One of the arguments of the function ode45() is a user-written MATLAB function which contains the state equations to be solved. A MATLAB user-written function resembles a short program or script except for the syntax of the first line of the code is an instruction, which “declares” the function. The declaration, or first line, of a MATLAB user-defined function begins with the key word “function” followed by an assignment statement where the left side is a variable name and the right side is the function name followed by the function’s argument list. The three dots or periods “…” are ellipses, the mathematical symbol for continuation of a series. Ellipses are MATLAB's operator to continue a statement on the following line.

figure t

The above syntax is generic for any function one wishes to create. The function containing the state equations to be solved by MATLAB’s Runge–Kutta solver ode45() expects just two arguments. The first argument is the independent variable t for time in our application. The second argument is the variable name of the state vector x. Attempting to pass other arguments to the function, which one can do with a normal user-written MATLAB function, will not work with the ode45() solving function. Parameter values and input functions must be written into to the user-written function. They cannot be passed to it as arguments.

7.4.1 Step Response of a Linear Mass-Damper System

We will illustrate creation of a user-written function and its solution, first with a mass-damper and then with a spring-mass-damper system. The state equation of the mass-damper system shown in Fig. 3.13 is repeated below for reference:

$$ \frac{{F( t )}}{M} = \frac{{d{v_{1g}}}}{{dt}} + \frac{b}{M}{v_{1g}}\,\,\,\,\,\, \to \,\,\,\,\,\,\frac{{d{v_{1g}}}}{{dt}} =- \frac{b}{M}{v_{1g}} + \frac{{F( t )}}{M} $$

The state variable is v 1g , the velocity of the mass.

The first step is to create a MATLAB user-defined function containing the state equations in MATLAB’s editor. The function declaration begins with the keyword “function.” The statement needs a variable name for the output of the function and a name for the function itself. We will name the variable dx and the function StateEq.  There are two arguments of the function. They must be the independent variable t for time in our applications, and the state vector x in that order.

figure u

The first line of code within the function is to define the variable dx as a vector variable with the number of elements equal to the number of state variables, one in this case. The instruction used to create (or allocate) a vector or array and fill it with zeros is named zeros(r, c), where r is the number of rows and c is the number of columns. A column vector has one column. The instruction to create the column vector dx with one element with the initial value of zero is:

figure v

The state equation is assigned to the element of the only element vector dx, dx(1). The state variable is also an element of the state vector x. It is the only element in the state vector x, x(1).

figure w

An end statement completes the function. Collecting the lines of code without the interspersed text:

figure x

The user-written MATLAB function is then saved using the function’s name and followed by the extension “.m.” In the command window, the following command runs MATLAB’s ode45() Runge–Kutta solver and writes the time data to the vector T and the values of the state variable to vector X.

figure y

The square brackets vectors. The elements in a vector can be separated by a blank space or a comma. Rows are separated by a semicolon. Note that the name of user- written function with the state equations is preceded by the at symbol, @. This is essential.

Fig. A7. 8
figure 48

Step response of a linear mass-damper system, M = 3, b = 2, F = 10

We will solve the state equation of the mass-damper system out to 12 sec and use zero as the initial value of the velocity of the mass.

figure z

The vector T contains the times of the calculations and X contains the values of the state variable at those times. The vectors T and X are plotted with the command:

figure aa

The result is shown in Fig. A7.8. Right clicking after having selected an object brings up a context menu for editing the plot. Select axes to label them and change their font size. Increase the thickness of the output trace.

7.4.2 Step Response of a Non-Linear Mass-Damper System

We can edit the state equations and add some types of non-linearities, such as a power law viscosity for the damping. We will square the velocity of the mass, x(1), in the state equation.

figure ab

Save this function as NLStateEq.m and run the Runge–Kutta solver ode45() with different names for the output time and state variable vector than used previously.

Fig. A7.9
figure 49

Linear and non-linear step response of a mass-damper system, M = 3, b = 2, F = 10

figure ac

We can now plot the linear and the non-linear step response of the mass-damper system on the same plot with the command:

figure ad

7.4.3 Response of a Linear Mass-Damper System Subjected to a Pulse Train

The independent variable t can be used in the state equations for the input function. We will use an if, elseif, else structure to create the input pulse:

$$ F(t)=5\,\,{{u}_{s}}\left( t \right)-10\,\,{{u}_{s}}\left( t-2 \right)+5\,\,{{u}_{s}}\left( t-4 \right). $$

Edit the first-order linear function StateEq(t, x) to add the if, elseif, and else, shown below to calculate the input force F(t).

figure ae

Save the edited function as PulseStateEq. m. Run the Runge–Kutta solver ode45() and plot the result with the commands:

figure af
Fig. A7.10
figure 50

Response of the linear mass-damper system, M amperb amper system, e linear mF(t)

7.4.4 Response of a Mass-Damper System to Sinusoidal Inputs

We use the independent variable t to drive the system with the input \( F(t) = 10\sin (2t) \)

figure ag

Save the function as SinStateEq. m, solve it with ode45() and plot it.

figure ah
Fig. A7.11
figure 51

Response of the linear mass-damper system, M = 3, b = 2, to the input F(t) = sin(2t). Notice the slightly blocky shape of the trace

figure ai

The quality of the response, Fig. A7.11, is disappointing. What should be pleasingly smooth sine curves are not. There are straight segments.

We must delve into the options available for ode45() reduce the blockiness. MATLAB has a built in function named odeset() for setting options for their ordinary differential solvers. The function odeset() exists because there are 22 options for ode solvers and you cannot pass just a single option value to the solver. It expects all 22 arguments. The function odeset() will accept a single option and its value. It then creates a file will the remaining option at their default values. The set of options is assigned to a variable name.

The option we will change is titled “refine.” MATLAB has a faster routine for refining the result of an ode solver than decreasing the time step. The refine option instructs the ode solver interpolate within a time step. To the user, it appears that the time step has been decreased. The default valve of refine for ode45() is four. We will double the value to eight. The syntax is:

figure aj

The variable name, options, is the last argument in the argument list of ode45

figure ak

The “refined” output is plotted in Fig. A7.12. The appearance of the trace is improved. It no longer has straight segments.

Fig. A7.12
figure 52

Response of the linear mass-damper system, M amperb amper system, e liF(t) = sin(2t). The “refine” option was increased from its default of four to eight

7.4.5 Step Response of a Spring-Mass-Damper System

Our final example will be to solve for the step response of the state variable and a number of output variables of the second-order linear spring-mass-damper system, shown in Fig. 7.5.

We will illustrate its use with the state equations of the mass-spring-damper system:

$$\frac{d}{{dt}}\left[ {\begin{array}{*{20}{c}}{{v_{1g}}} \\ {{F_K}}\end{array}} \right] = \left[ {\begin{array}{*{20}{c}} { - \frac{b}{M}}&{ - \frac{1}{M}} \\ K&0\end{array}} \right]\left[ {\begin{array}{*{20}{c}} {{v_{1g}}} \\ {{F_K}}\end{array}} \right] + \left[ {\begin{array}{*{20}{c}} {\frac{1}{M}} \\ 0\end{array}} \right]F$$

The MATLAB code requires individual equations. Expanding the matrix form:

$$ \begin{aligned} & \frac{d{{v}_{1g}}}{dt}=-\frac{b}{M}{{v}_{1g}}-\frac{1}{M}{{F}_{K}}+\frac{1}{M}F \\ & \frac{d{{F}_{K}}}{dt}=K{{v}_{1g}} \\\end{aligned} $$

It is always worth the time to define which state variable is which. In this case, \( {v_{1g}} \equiv {x_1} \) and \( {F_K} \equiv {x_2} \)

We will name the variable dx and the function StateEqs. The two arguments of the function must be t for time and x for the state vector, in that order.

The first line of code within the function is to define the variable dx as a vector with the number-of-elements equation to the number of state variables, two in this case. The instruction to create the column vector dx with two elements with the initial values of zero is:

Fig. A7.13
figure 53

Step response of the linear spring-mass-damper system, M ampe b amper sK amper system, of F  = 10

figure al

The output equations are purely algebraic equations. They are solved after the state equations have been solved and the state variables are known. We must expand the output equations from vector-matrix form into a set of equations in order to program them.

$$ \left[ \begin{matrix} {{v}_{1g}} \\ {{F}_{K}} \\ {{F}_{M}} \\ {{F}_{b}} \\\end{matrix} \right]=\left[ \begin{matrix} 1 & 0 \\ 0 & 1 \\ -b & -1 \\ b & 0 \\\end{matrix} \right]\left[ \begin{matrix} {{v}_{1g}} \\ {{F}_{K}} \\\end{matrix} \right]+\left[ \begin{matrix} 0 \\ 0 \\ 1 \\ 0 \\\end{matrix} \right]F\,\,\,\,\,\,\to \,\,\,\,\,\,\begin{matrix} {{v}_{1g}}={{v}_{1g}}\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\, \\ {{F}_{K}}={{F}_{K}}\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\, \\ {{F}_{M}}=-b{{v}_{1g}}-{{F}_{K}}-F \\ {{F}_{b}}=b{{v}_{1g}}\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\, \\\end{matrix} $$

The time values are in the vector variable T. Its length can be determined by the function length(). The state variables v1g and FK are the columns in the state vector X and should be extracted and assigned to individual vector variables. MATLAB’s “colon operator”,:, is a wildcard to force a variable to take on every value in a range. The colon operator successively takes on the values of the row indices, allowing the columns of the array to be copied to vectors without the use of a for end loop.

figure am

The output variables are calculated with a for loop.

figure an
Fig. A7.14
figure 54

Step response of the output variables FM and Fb of a linear spring-mass-damper system, M amperb amperK amper system, of F  = 10

Rights and permissions

Reprints and permissions

Copyright information

© 2014 Springer Science+Business Media New York

About this chapter

Cite this chapter

Seeler, K. (2014). Vector-Matrix Algebra and the State-Space Representation of Dynamic Systems. In: System Dynamics. Springer, New York, NY. https://doi.org/10.1007/978-1-4614-9152-1_7

Download citation

  • DOI: https://doi.org/10.1007/978-1-4614-9152-1_7

  • Published:

  • Publisher Name: Springer, New York, NY

  • Print ISBN: 978-1-4614-9151-4

  • Online ISBN: 978-1-4614-9152-1

  • eBook Packages: EngineeringEngineering (R0)

Publish with us

Policies and ethics