# How to implement tightly coupled nonlinear odes using ode45 in matlab?

4 views (last 30 days)

Show older comments

##### 8 Comments

### Accepted Answer

Torsten
on 12 Nov 2018

Solve the equations

t*x2 - x1*x2' = t^2*x1 + x2*x1'

x1'' + x2'' = t*x2 - x1*x2'

Setting

y1 = x1

y2 = x1'

y3 = x2

y4 = x2'

you arrive at the system

y1' = y2

y2' + y4' = t*y3 - y1*y4

y3' = y4

y1'*y3 + y1*y3' = t*y3 - t^2*y1

Now either solve for y1', y2, y3' and y4' in each time step or use the mass matrix facility of the ODE solvers by writing your system as

M(t,y)*y' = F(t,y)

with

M = [1 0 0 0; 0 1 0 1; 0 0 1 0; y3 0 y1 0]

F = [y2;t*y3-y1*y4;y4;t*y3-t^2*y1]

Best wishes

Torsten.

##### 0 Comments

### More Answers (1)

Vikash Pandey
on 12 Nov 2018

##### 12 Comments

Sam Chak
on 6 Dec 2022

Hi @Huy Nguyen

Would advise you to post your specific problem in a New Question. Also to clarify whether it's a math-related problem or a technical problem in MATLAB code.

### See Also

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!