# Thread: Solving IVP in Matlab (ode45)

1. ## Solving IVP in Matlab (ode45)

Good day to you!

I want to solve an IVP in matlab, given by

$\displaystyle x_1 ' (t) = -4*10^{-2} x_1(t) +3*10^7 x_2(t)x_3(t)$

$\displaystyle x_2'(t) = 4*10^{-2}-10^{4}x_2(t)x_3(t) - 3*10^7x_2^2(t)$

$\displaystyle x_3'(t) = 3*10^7 x_2^2(t)$

I tried to write this as a first order vector

$\displaystyle \dot{x} = \begin{pmatrix} -4*10^{-2} & 3*10^7 & 3*10^7 \\ ... & ...&...\\...&...&...\end{pmatrix}*x$

Because of $\displaystyle x_2(t)x_3(t)$ (or because of the first line in the matrix) I think this does not work that way.

Thanks for spending time on my problem/posting.

Kind regards,
Rapha

2. Originally Posted by Rapha
Good day to you!

I want to solve an IVP in matlab, given by

$\displaystyle x_1 ' (t) = -4*10^{-2} x_1(t) +3*10^7 x_2(t)x_3(t)$

$\displaystyle x_2'(t) = 4*10^{-2}-10^{4}x_2(t)x_3(t) - 3*10^7x_2^2(t)$

$\displaystyle x_3'(t) = 3*10^7 x_2^2(t)$

I tried to write this as a first order vector

$\displaystyle \dot{x} = \begin{pmatrix} -4*10^{-2} & 3*10^7 & 3*10^7 \\ ... & ...&...\\...&...&...\end{pmatrix}*x$

Because of $\displaystyle x_2(t)x_3(t)$ (or because of the first line in the matrix) I think this does not work that way.

Thanks for spending time on my problem/posting.

Kind regards,
Rapha
THis just like the other problem, set up a function with the derivative:

Code:
function dx=deriv(t,x)
dx=zeros(size(x);
dx(1)=-4*10^(-2)* x(1) +3*10^7 *x(2)*x(3);
dx(2)=4*10^(-2)-10^(4)*x(2)*x(3) - 3*10^7*x(2);
dx(3)=3*10^7 *x(2)^2;
CB

3. Hello CB!

Originally Posted by CaptainBlack
THis just like the other problem,
Wow, you remember that?! Long memory...

Originally Posted by CaptainBlack
THis just like the other problem,
The IVPs are so confusing.

Originally Posted by CaptainBlack
set up a function with the derivative:

Code:
function dx=deriv(t,x)
dx=zeros(size(x);
dx(1)=-4*10^(-2)* x(1) +3*10^7 *x(2)*x(3);
dx(2)=4*10^(-2)-10^(4)*x(2)*x(3) - 3*10^7*x(2);
dx(3)=3*10^7 *x(2)^2;
CB
Thank you for the code! This helps me to understand the problem.

Best wishes, Rapha