Sunteți pe pagina 1din 4

ECE 509 Analysis of Linear Systems

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

(voltage across the capacitor), and suppose the system

output is the inductor current.


For this problem the matlab commands lsim and ss will be useful. The following code
is just an example (so make sure you modify the A, B, C and D matrices to match the
dynamics from the circuit):
A=[1, 2; 3, 4]; B=[-1; 0]; C=[1, 0]; D=0;
plant=ss(A,B,C,D);
x0=[1; 1];
conditions
t=[0:0.5:10];
u=zeros(1, length(t));
[y,t,x]=lsim(plant, u, t, x0);

% define the plant


% initial
% time vector
% input vector
% simulate

Produce two plots: in the first one you will plot the state
the state

x2

x1

versus time in a subplot and

versus time in another subplot. In the second figure, plot

x2

versus

x1

(MATLAB hint: plot(x(:,1),x(:,2)) will do the trick).


Think about what you have just produced: the plane

x2

versus

x1

is the state space of

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.

What happens? Why?


5.

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

Fsp= K(y) = k(1+ a 2 y 2 )y


where

is the displacement,

k = 0.7

is the spring constant, and

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:

a) The spring is ideal.


b) The spring is a hardening spring as given above.

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.

Consider the Design Application #2, the inverted pendulum on a cart.


a) Letting the motion be described by the generalized coordinates y and

, compute

Lagranges equations for this system.


b) Assume that the angle is kept small (that is, the system operates in the linear
region), so that the approximations

cos 1 and sin

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)

state equation we got in class!


d) Suppose now we consider the realistic problem of having a DC motor (as discussed in
Design Application #1) supply the external force. To this end, assume that the
relation between the (linear) force f and the (rotational) torque is given by fr=,
where r is the wheel radius, and assume that the motor operates at 100% efficiency,
with motor torque constant k. Working from the linearized dynamical equations

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 )
(

S-ar putea să vă placă și