Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
ode45

Subject: ode45

From: Ricardo

Date: 29 Jun, 2011 10:49:09

Message: 1 of 6

hello

I would like to resolve a differential equation problem using a matlab.

I start to do examples with ode45, but to resolve my problem I don't know if it is the right ode function to use.

The problem look like that

x'' = x' + x + y'' + y
y'' = x'' + x + y' + y

I also have initial values for x' , x , y' and y

I can't implement two equations who use terms in 2nd order on both.

Any ideia to resolve that?

Subject: ode45

From: Nasser M. Abbasi

Date: 29 Jun, 2011 11:05:46

Message: 2 of 6

On 6/29/2011 3:49 AM, Ricardo wrote:
> hello
>
> I would like to resolve a differential equation problem using a matlab.
>
> I start to do examples with ode45, but to resolve my problem I don't know if it is the right ode function to use.
>
> The problem look like that
>
> x'' = x' + x + y'' + y
> y'' = x'' + x + y' + y
>
> I also have initial values for x' , x , y' and y
>
> I can't implement two equations who use terms in 2nd order on both.
>
> Any ideia to resolve that?

You must have an error somewhere. There is no non-trivial solution
to x'' and y'' from the above coupled ode's.

if you put y=0 and x'=-2x then it satisfies the above.

If you have coupled ode's and want to use ode45, the first step
is to decouple them. Then the rest is easy.

--Nasser

Subject: ode45

From: Ricardo

Date: 29 Jun, 2011 13:24:10

Message: 3 of 6

"Nasser M. Abbasi" <nma@12000.org> wrote in message <iuf0ua$4fg$1@speranza.aioe.org>...
> On 6/29/2011 3:49 AM, Ricardo wrote:
> > hello
> >
> > I would like to resolve a differential equation problem using a matlab.
> >
> > I start to do examples with ode45, but to resolve my problem I don't know if it is the right ode function to use.
> >
> > The problem look like that
> >
> > x'' = x' + x + y'' + y
> > y'' = x'' + x + y' + y
> >
> > I also have initial values for x' , x , y' and y
> >
> > I can't implement two equations who use terms in 2nd order on both.
> >
> > Any ideia to resolve that?
>
> You must have an error somewhere. There is no non-trivial solution
> to x'' and y'' from the above coupled ode's.
>
> if you put y=0 and x'=-2x then it satisfies the above.
>
> If you have coupled ode's and want to use ode45, the first step
> is to decouple them. Then the rest is easy.
>
> --Nasser
>
>
>
ok, but I didn't explaine well
x''(t) = x'(t) + x(t) + y''(t) + y(t)
y''(t) = x''(t) + x(t) + y'(t) + y(t)

I think, I can't do that what you suggest...I suppose

Subject: ode45

From: Nasser M. Abbasi

Date: 29 Jun, 2011 18:16:52

Message: 4 of 6

On 6/29/2011 6:24 AM, Ricardo wrote:
> "Nasser M. Abbasi"<nma@12000.org> wrote in message<iuf0ua$4fg$1@speranza.aioe.org>...


>> On 6/29/2011 3:49 AM, Ricardo wrote:
>>> hello
...
>>> The problem look like that
>>>
>>> x'' = x' + x + y'' + y
>>> y'' = x'' + x + y' + y
>>>

>>
>> You must have an error somewhere. There is no non-trivial solution
>> to x'' and y'' from the above coupled ode's.
>>
>> if you put y=0 and x'=-2x then it satisfies the above.
>>
>> If you have coupled ode's and want to use ode45, the first step
>> is to decouple them. Then the rest is easy.
>>
>> --Nasser
>>


>>
> ok, but I didn't explaine well
> x''(t) = x'(t) + x(t) + y''(t) + y(t)
> y''(t) = x''(t) + x(t) + y'(t) + y(t)
>
> I think, I can't do that what you suggest...I suppose

You did not say anything new. You still must have a typo
or some error.

Try to solve for x'' and y'' first. Can you do that? use paper
and pencil. no computer is needed. You have 2 equations above
and 2 unknowns, x'' and y''. Solve for them and you will see
there is no solution.

If you can't decouple them, I do not see a way to use ode45
on them togother. ode45 works on first order set of ode's.

to make this set of ode's you need to start with decoupled
ode's.

--Nasser

Subject: ode45

From: Roger Stafford

Date: 29 Jun, 2011 19:10:28

Message: 5 of 6

"Ricardo " <rhicardo.af@gmail.com> wrote in message <iuf91q$rej$1@newscl01ah.mathworks.com>...
> ok, but I didn't explaine well
> x''(t) = x'(t) + x(t) + y''(t) + y(t)
> y''(t) = x''(t) + x(t) + y'(t) + y(t)
>
> I think, I can't do that what you suggest...I suppose
- - - - - - - - - - -
  You have to do some initial algebra on your two equations before submitting them to ode45. The ode solver is simply not smart enough to do this for you.

  Adding the two equations and manipulating will give you this:

 x'+y' = -2*(x+y)

  Subtracting them and more manipulation will produce this:

 x"-y" = 1/2*(x'-y')

  This tells you to define new variables u = x+y and v1 = x-y, v2 = x'-y' and to make two separate calls on ode45 using your known initial values:

The first call would be:

 du/dt = -2*u

and the second call is:

 dv2/dt = 1/2*v2
 dv1/dt = v2

From the solutions u and v, you can then derive x and y. (Of course we all know from calculus what these solutions will be without even bothering to use ode45.)
 
  Note that your initial values for x', y', x, and y are interdependent and must satisfy x'+y'+2*x+2*x = 0. That is, these equations have only three independent parameters.

Roger Stafford

Subject: ode45

From: Roger Stafford

Date: 29 Jun, 2011 19:41:10

Message: 6 of 6

"Roger Stafford" wrote in message <iuftb4$2gp$1@newscl01ah.mathworks.com>...
> Note that your initial values for x', y', x, and y are interdependent and must satisfy x'+y'+2*x+2*x = 0. That is, these equations have only three independent parameters.
- - - - - - - -
  Oops, I meant x'+y'+2*x+2*y = 0.

Roger Stafford

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us