Thread: ode45 Matlab
View Single Post
  #2  
Old November 26th, 2008, 11:07 PM
CaptainBlack's Avatar
CaptainBlack CaptainBlack is offline
Grand Panjandrum
 
Join Date: Nov 2005
Location: South of England
Posts: 11,375
Country:
Thanks: 667
Thanked 3,618 Times in 2,915 Posts
CaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond repute
Default

Quote:
Originally Posted by Rapha View Post
Hello everyone!

I need to solve a IVP, for example

\dot{x} = x + 2\dot{y} + y

\dot{y} = y - 2\dot{x} + 5x

x(0) = 0.995
y(0) = 0

(I actually don't know if there is a solution...)

But how to solve it by using ode45? \dot{x} depends on \dot{y} and y ...

By the way,
I know how to solve

\dot{v}(t) = 10 - 5/2*v^2(t), t\in [0, 10]

v0 = v(0) = 0

for example:

[ t , v ] = ode45 (@( t , v ) 10-5v^2/2 , [0, 10], v0 ) ;


----
How to solve the IVP with 2 equations?

Best regards,
Rapha
Eliminate the \dot{y} term in the first equation by substituting from the second, and \dot{x} for the second by substituting from the first:

\dot{x}=\frac{11x+2y}{5}

\dot{y}=\frac{-2x-y}{5}

So now writing this as a first order vector ODE:

\dot{\bold{x}}=\left[\begin{array}{cc}11/5 & 2/5\\-2/5 & -1/5\end{array}\right] {\bold{x}}

where:

{\bold{x}}=\left[\begin{array}{c}x\\y\end{array}\right]

So now can you get ode45 to work?

CB
__________________
Truth does not change because it is, or is not, believed by a majority of the people.

Giordano Bruno
Reply With Quote
The following users thank CaptainBlack for this useful post:
Donate to MHF