Question

QUESTION 6

Having gained initial familiarity with Matlab we'll now look at using it for helping solve problems specific to Signals and Systems.

Selving Ordinary Differential Equations ODE)

in continuous time, systems are governed by ODES. For example, for the simple RC circuit below, if we call the input voltage aft) and the output voltage, the voltage across the capacitor, y

x(t)

R=392

www

you should be able to analyse it using Kirchhoff's current and voltage laws to show that the relationship between the input and the output is given by

symy

>>egn- 3*diffytyt-diracik

>>cond-y-1) --Q

>>h-dsolveen.com

You should also be able to solve this ODE by hand. (It's not mandatory, but you might like to give this deviation and solution of the ODE a go

We can also use Matlab to solve the ODE for us. This is very helpful for when dealing with more complicated systems in the future.

Matlab cannot solve the generic CDE, we need to tell it what the input xt is before it can solve it. To solve the ODE to find the impulse response file. when x(1) má()) we can use the commands

C=1F

>>pretty

Let's walk through these commands.

syms is used to tell Matlab what we want to call our signals. Here we just tell it we'll have one variable yit) which we'll use to represent the system output.

egn is the name we've given to the ODE we want to solve. The differential term is written as diffyt otherwise the ODE is typed in directly following the Maths except that Matlab wants two equals signs() rather than one. That's just the syntax Matlab expects. Here we've not typed inx) for the

input. In this case we are finding the impulse response and so we have set it to be an impulse diract) is how Matlab represents an impulse function, what we would write as (1) mathematically

* mchusac? • Desktop

• cond is the variable containing our initial conditions. For a first order ODE we need one initial condition to be able to solve it. Here we've said that y(-1)-0. That is, that the output is at rest at time-1. In this course we'll always assume the system is at rest before time-0. (We thus could have used (2)

ory(3) or any time before 0. Note that we can't use t0) to give the initial condition-the output might not be 0 then, the system is only at rest for time<0.)

dsolve is the main command used to solve the ODE, storing the answer in a variable called h. It takes two arguments: the equation to solve, and the initial conditions.

The pretty command displays the solution of the ODE in the main Matlab window.

Run the above code in Matlab. Matlab should display the equation as something like

y(t)

>> syms y(t);

egn 3 diff(y,t) + y(t) dirac (t);

hdsolve (eqn, "y(-1)-0¹)

pretty(h)

/t\

exp (sign(t) + 1)

This is a little different to how we would write the equation by hand. By hand we would write

We use a unit step function, ut which is 0 for values of t

(signisfort0 and 1 fort>0 and so Matlab is actually adding two copies of the signal together to get the compete one, and for negative times one copy has been multiplied by such that the two parts sum to 0. Try drawing this out, or ask a demonstrator for help, and you'll see how this sets the

output to be for times before)

For this course we mainly want to focus on the exp term, and what it tells us about the system. Ignore the sign) + 1"term, which is just used to ensure the Maths is fully correct, and focus on the exp term and what is inside its brackets.

Looking at the equation for the system output, and what you would expect from circuit theory, what is the time constant of this system? (Remember to include a unit if one is required)

Question image 1