# Solving IVP in Matlab (ode45)

• Dec 15th 2008, 08:36 PM
Rapha
Solving IVP in Matlab (ode45)
Good day to you!

I want to solve an IVP in matlab, given by

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

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

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

I tried to write this as a first order vector

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

Because of $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
• Dec 15th 2008, 09:49 PM
CaptainBlack
Quote:

Originally Posted by Rapha
Good day to you!

I want to solve an IVP in matlab, given by

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

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

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

I tried to write this as a first order vector

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

Because of $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
• Dec 15th 2008, 10:01 PM
Rapha
Hello CB!

Quote:

Originally Posted by CaptainBlack
THis just like the other problem,

Wow, you remember that?! Long memory...

Quote:

Originally Posted by CaptainBlack
THis just like the other problem,

The IVPs are so confusing.

Quote:

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