Documente Academic
Documente Profesional
Documente Cultură
Homework 1
Due: Tuesday, January 27, 2015
The main objective of this homework is to get an intuitive feel of what the state variables and
state equations mean. As a benefit, you will also learn some new and useful MATLAB
commands for simulation of dynamical systems.
1.
Derive the state variable equations for the following circuit, where you should use the
current through the inductor and the voltage across the capacitor as your state variables:
Assume that L=0.5 H, C=0.5 F, R=2 Ohm. Express the state equations in matrix form,
similar to how we did it in class for the inverted pendulum.
2.
Using MATLAB, simulate the circuit in Problem 1, where the input current is kept equal to
zero (u=0). Let the simulation run for 10 seconds, and use a sufficiently small time step
(0.01 may be a good value). Use the initial condition iL (0) = 0.5A (current through the
inductor) and
vC (0) = 1.5V
Produce two plots: in the first one you will plot the state
the state
x2
x1
x2
versus
x1
x2
versus
x1
this system, and the plot you just produced is called a state trajectory.
Do you think there exists some initial condition for which the state trajectory does not
converge to zero? Why or why not?
3.
Now the current source in Problem 1 will produce a square wave between -2 and 2
Amperes, and a period equal to 20 seconds. Simulate the system for 30 seconds and
produce the same kinds of plots as in Problem 2.
The commands gensig or square will be helpful here. Try help gensig and help
square.
Why does the value of the inductor current seem to converge to -1 and 1, alternatively?
How about the capacitor voltage?
Explain what you observe in the state space! How does the state space plot relate with the
time plots for x1 and x 2 ?
4.
Now we will replace the resistor with an active circuit (for example, made with op-amps)
that behaves like a negative resistance, so that now R=-2 Ohms. Set the input current to
zero again, and simulate the system for 3 or 4 seconds. Produce the state trajectory plot.
We will now simulate a nonlinear system. Consider the mass-spring system with friction:
The mass is equal to 1 kg. We will assume that the friction force is ideal, with friction
constant B=0.5 (so that F fr = By ). The spring is nonlinear, and it is a so-called
hardening spring. For this kind of spring, beyond a certain displacement, a small
displacement produces a large force increment. We model such a spring with
is the displacement,
k = 0.7
a =1
is a nonlinearity
constant.
In order to simulate a nonlinear system you need to use a numerical method that solves
the nonlinear differential equations. In matlab, you do this with the command ode23. The
following is an example that shows how to simulate the system given by:
x1 = x2
x2 = 0.1x1 0.2x2 + u
(THIS IS JUST AN EXAMPLE! YOU MUST MODIFY IT TO MATCH THE MASS-SPRING SYSTEM
DYNAMICS)
In your main m-file (suppose it is called example.m):
% set initial conditions
x0=[1;1];
% simulate
[t,x]=ode23('derivatives_function',60,x0);
plot(t,x(:,1));
You also need to create a separate m-file called derivatives_function.m:
function [x_dot] = derivatives(t, x)
u=0.3*cos(t);
% the input to the plant
x_dot(1) = x(2);
% the first state's derivative
x_dot(2) = -0.1*x(1) - 0.2*x(2) + u; % the second state's derivative
x_dot = x_dot';
% need to return a column vector
The function derivatives must return the derivatives of the states. To run the simulation,
you need to run example.m. In your case, make sure to program the derivatives
corresponding to the mass-spring system.
Assume that the initial condition is x1 = x 2 = 5 . The input force to the system is kept
equal to zero (u=0). Derive a state variable representation of the mass-spring system
where the states are the position y and the velocity y of the mass. Simulate the system
for 60 seconds, and produce state space plots for two cases:
Give an interpretation of the plots and the differences in the state trajectories. How do you
explain the behavior when the nonlinear spring is used?
6.
, compute
are valid, and that terms in y and are negligible so that quadratic terms may be
neglected. Derive the lizearized model of this system under these conditions.
T
Define the state vector x = [y,, y , ] and put the system into standard state variable
form; that is,
formulate the equation
x = Ax + Bu
where the input u is the external force f on the cart. Note: you should get the same
c)
derived above, show that the differential equations describing the overall system can
be written as
mg
1$ k
k2 '
+ & e 2 y )
M
M % Rr
Rr (
$ M + m'
1 $ k
k2
= &
g
)
&
% Ml (
Ml % Rr
Rr 2
y =
'
y )
(