Difference equations with initial and final condition in matlab

357 Views Asked by At

Consider the following equations: enter image description here

x_1(k+1) = 2x_1(k) + 0.2x_2(k)
x_2(k+1) = 2x_2(k) - 0.4λ_2(k)
λ_1(k) = 0.1x_1(k) + 2λ_1(k+1)
λ_2(k) = 0.2λ_1(k+1) + 2λ_2 k+1)

k=0, 1, 2… 10
x_1(0)=2                       x_2(0)=0                        
x_1(10)=0                   x_2(10)=0     

How can I determine x_1(k) , x_2(k) , λ_1(k) , λ_2(k) for k=0,...,10 in Matlab(m-file)?

1

There are 1 best solutions below

1
PreußensGloria On

When you are trying to solve equation systems you can go several ways.

Since this looks like a sort of differential equation with an approximation step number of k=10. You can try to use something like ode45.

For this you have to redefine your problem like it is shown in the Matlab documentation for ode45 under the section of higher order differential equations. You can find the documentation and many examples here: https://de.mathworks.com/help/matlab/ref/ode45.html

You could also rewrite your problem in a matrix vector notation and solve it easily using the matlab mldivide command. For further information you can check here: https://de.mathworks.com/help/matlab/ref/mldivide.html