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:
Solving system of ODEs

Subject: Solving system of ODEs

From: Apon Mohaimen

Date: 29 Jan, 2012 11:14:10

Message: 1 of 10

Dear all,
I was just wondering if anyone knows how to solve a system of ODE's of the following form:
dx/dt=f(x)
dy/dt=g(x)
x0=0,y0=0
note that both x' and y' prime are only functions of x only.
Do i need to include '0*h(y)' in one of the equations so that Matlab understands that it needs to solve for both x and y?

Subject: Solving system of ODEs

From: Nasser M. Abbasi

Date: 29 Jan, 2012 11:47:30

Message: 2 of 10

On 1/29/2012 5:14 AM, Apon Mohaimen wrote:
> Dear all,
> I was just wondering if anyone knows how to solve a system of ODE's of the following form:
> dx/dt=f(x)
> dy/dt=g(x)
> x0=0,y0=0
> note that both x' and y' prime are only functions of x only.
> Do i need to include '0*h(y)' in one of the equations so that Matlab understands that
>it needs to solve for both x and y?


dy/dt=g(x)? I do not underatand this one. is y here a function
of t and x?

--Nasser

Subject: Solving system of ODEs

From: Apon Mohaimen

Date: 29 Jan, 2012 15:08:09

Message: 3 of 10

"Nasser M. Abbasi" <nma@12000.org> wrote in message <jg3bki$uu5$1@speranza.aioe.org>...
> On 1/29/2012 5:14 AM, Apon Mohaimen wrote:
> > Dear all,
> > I was just wondering if anyone knows how to solve a system of ODE's of the following form:
> > dx/dt=f(x)
> > dy/dt=g(x)
> > x0=0,y0=0
> > note that both x' and y' prime are only functions of x only.
> > Do i need to include '0*h(y)' in one of the equations so that Matlab understands that
> >it needs to solve for both x and y?
>
>
> dy/dt=g(x)? I do not underatand this one. is y here a function
> of t and x?
>
> --Nasser
Thanks for your reply. Actually both x and y are indeed functions of t. dy/dt is a function of x and t. Does it make sense if I write it this way?
dx(t)/dt=f(x(t),t)
dy(t)/dt=g(x(t),t)
x(0)=0,y(0)=0

Subject: Solving system of ODEs

From: TideMan

Date: 29 Jan, 2012 19:49:57

Message: 4 of 10

On Jan 30, 4:08 am, "Apon Mohaimen" <mohaimen.man...@gmail.com> wrote:
> "Nasser M. Abbasi" <n...@12000.org> wrote in message <jg3bki$uu...@speranza.aioe.org>...> On 1/29/2012 5:14 AM, Apon Mohaimen wrote:
> > > Dear all,
> > > I was just wondering if anyone knows how to solve a system of ODE's of the following form:
> > > dx/dt=f(x)
> > > dy/dt=g(x)
> > > x0=0,y0=0
> > > note that both x' and y' prime are only functions of x only.
> > > Do i need to include '0*h(y)' in one of the equations so that Matlab understands that
> > >it needs to solve for both x and y?
>
> > dy/dt=g(x)? I do not underatand this one.  is y here a function
> > of t and x?
>
> > --Nasser
>
> Thanks for your reply. Actually both x and y are indeed functions of t. dy/dt is a function of x and t. Does it make sense if I write it this way?
> dx(t)/dt=f(x(t),t)
> dy(t)/dt=g(x(t),t)
> x(0)=0,y(0)=0

So, dy/dt must be a partial derivative, not ordinary derivative, and
that's a whole different ballgame.

Subject: Solving system of ODEs

From: Bruno Luong

Date: 29 Jan, 2012 20:25:10

Message: 5 of 10

"Apon Mohaimen" wrote in message <jg39m2$m4$1@newscl01ah.mathworks.com>...
> Dear all,
> I was just wondering if anyone knows how to solve a system of ODE's of the following form:
> dx/dt=f(x)
> dy/dt=g(x)
> x0=0,y0=0
> note that both x' and y' prime are only functions of x only.
> Do i need to include '0*h(y)' in one of the equations so that Matlab understands that it needs to solve for both x and y?

I don't agree with Tideman, there is no partial derivative here. I propose two ways of solving the problem:

1. 1st Option

Let's define

X = [x; y]
H(X) = [f(x); g(x)];
X0 = [x0; y0];

Then solve
dX/dt = H(X)
X(t=0) = X0

using Matlab ode solver.

2nd option:

Because x does not depend on y. Solve for x the system:
dx/dt=f(x)
x(t=0) = x0=0

using MATLAB ode solver.

Then compute y as integral:

y(t) = y0 + integral_on (0,t) (g(x(s)) ds.

Using numerical integration.

Bruno

Subject: Solving system of ODEs

From: TideMan

Date: 29 Jan, 2012 20:34:19

Message: 6 of 10

On Jan 30, 9:25 am, "Bruno Luong" <b.lu...@fogale.findmycountry>
wrote:
> "Apon Mohaimen" wrote in message <jg39m2$m...@newscl01ah.mathworks.com>...
> > Dear all,
> > I was just wondering if anyone knows how to solve a system of ODE's of the following form:
> > dx/dt=f(x)
> > dy/dt=g(x)
> > x0=0,y0=0
> > note that both x' and y' prime are only functions of x only.
> > Do i need to include '0*h(y)' in one of the equations so that Matlab understands that it needs to solve for both x and y?
>
> I don't agree with Tideman, there is no partial derivative here. I propose two ways of solving the problem:
>
> 1. 1st Option
>
> Let's define
>
> X = [x; y]
> H(X) = [f(x); g(x)];
> X0 = [x0; y0];
>
> Then solve
> dX/dt = H(X)
> X(t=0) = X0
>
> using Matlab ode solver.
>
> 2nd option:
>
> Because x does not depend on y. Solve for x the system:
> dx/dt=f(x)
> x(t=0) = x0=0
>
> using MATLAB ode solver.
>
> Then compute y as integral:
>
> y(t) = y0 + integral_on (0,t) (g(x(s)) ds.
>
> Using numerical integration.
>
> Bruno

But if y(x,t), then:
dy/dt=pdy/pdt + dx/dt pdy/pdx where pd=> partial derivative

Subject: Solving system of ODEs

From: Bruno Luong

Date: 29 Jan, 2012 20:53:10

Message: 7 of 10

TideMan <mulgor@gmail.com> wrote in message <f70bc1a9-d167-46e4-9b7b-b54afbdfa2d1@1g2000yqv.googlegroups.com>...

>
> But if y(x,t), then:
> dy/dt=pdy/pdt + dx/dt pdy/pdx where pd=> partial derivative

The PDE implies the unknown is multivariate function with system involving the partial derivative of the unknown.

The relation you show is how to compute the derivative from a composed function TideMan. This does not change the fact that the system is simply an ODE, no more.

Bruno

Subject: Solving system of ODEs

From: Roger Stafford

Date: 29 Jan, 2012 22:25:09

Message: 8 of 10

TideMan <mulgor@gmail.com> wrote in message <bffb24ab-e1bb-4c17-9f26-da4abfbf485e@h6g2000yqk.googlegroups.com>...
> So, dy/dt must be a partial derivative, not ordinary derivative, and
> that's a whole different ballgame.
- - - - - - - - - -
  In a sense both statements are true. There is a partial derivative involved. However when we write

 dy/dt=g(x,t)

for solution by 'ode' it is the total derivative that is meant:

 dy/dt = g(x(t),t)

regarding g(x(t),t) as a function solely of t and not the partial derivative with respect to the second argument. Hence it is perfectly acceptable as a problem for the 'ode' routines.

Roger Stafford

Subject: Solving system of ODEs

From: Michael Bernard

Date: 29 Jan, 2012 23:07:10

Message: 9 of 10


Dear Apon Mohaimen

You will need to solve your own problem. Go to the website http://www.freebookspot.es/Default.aspx
Download a book called Solving ODEs with MATLAB by Shampine Gladwell Thompson.

Just copy the title of this book and U will find it. This book has the answer to your problems and many more.You can use it to help yourself.I hope I tried.

All the best

Cheers!!!




"Apon Mohaimen" wrote in message <jg39m2$m4$1@newscl01ah.mathworks.com>...
> Dear all,
> I was just wondering if anyone knows how to solve a system of ODE's of the following form:
> dx/dt=f(x)
> dy/dt=g(x)
> x0=0,y0=0
> note that both x' and y' prime are only functions of x only.
> Do i need to include '0*h(y)' in one of the equations so that Matlab understands that it needs to solve for both x and y?

Subject: Solving system of ODEs

From: Michael Bernard

Date: 29 Jan, 2012 23:09:10

Message: 10 of 10

Dear Nasser

I guess you and Apon have the same problem so I will send the same message.

You will need to solve your own problem. Go to the website http://www.freebookspot.es/Default.aspx
Download a book called Solving ODEs with MATLAB by Shampine Gladwell Thompson.

Just copy the title of this book and U will find it. This book has the answer to your problems and many more.You can use it to help yourself.I hope I tried.

All the best

Cheers!!!





"Nasser M. Abbasi" <nma@12000.org> wrote in message <jg3bki$uu5$1@speranza.aioe.org>...
> On 1/29/2012 5:14 AM, Apon Mohaimen wrote:
> > Dear all,
> > I was just wondering if anyone knows how to solve a system of ODE's of the following form:
> > dx/dt=f(x)
> > dy/dt=g(x)
> > x0=0,y0=0
> > note that both x' and y' prime are only functions of x only.
> > Do i need to include '0*h(y)' in one of the equations so that Matlab understands that
> >it needs to solve for both x and y?
>
>
> dy/dt=g(x)? I do not underatand this one. is y here a function
> of t and x?
>
> --Nasser

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