Thread Subject: Solving 2nd order ode in Simulink

Subject: Solving 2nd order ode in Simulink

From: Emeka Obe

Date: 30 Dec, 2008 19:03:03

Message: 1 of 3

Hello,

It looks like if one cascades two integrators, he does not get a 2nd order ode solved.

For example, my 2n order ode is:

y'' + gy = Msin(wt).

g is a constant.

The solution to this ode shd be a sine function. When I cascade two integrators, I do not see a sine function resulting in simulink. Why?

I also noticed that if one used a sine block (Msinwt) as input to an integrator, he gets the output of the integrator as M+Mcos(wt). Why not just Mcos(wt)?

Can someone provide a solution to these?

ES

Subject: Solving 2nd order ode in Simulink

From: Phil Goddard

Date: 31 Dec, 2008 00:38:01

Message: 2 of 3


You need to revise the fundamentals of integration:

> I also noticed that if one used a sine block (Msinwt) as input to an integrator, he gets the output of the integrator as M+Mcos(wt). Why not just Mcos(wt)?

The integral of a sine wave is the negative of a cosine plus a constant, where the value of the constant is the value of the cosine at t = t0.
So for u = sin(t), integrated from t0=0, the integral is 1-cos(t).
Not surprisingly this is what Simulink gives.

> For example, my 2n order ode is:
>
> y'' + gy = Msin(wt).
>
> g is a constant.
>
> The solution to this ode shd be a sine function.

I can't think of a case where the solution is a pure sine wave.
For the (easy) case of g = M = w = 1 the solution is y = -0.5 * t * cos(t).
Again, not surprisingly this is what Simulink gives.
For the more generic case y will be something like a*sin(wt) + b*cos(wt) where a and b are functions of g, M and w.

Phil.

Subject: Solving 2nd order ode in Simulink

From: Phil Goddard

Date: 31 Dec, 2008 08:19:04

Message: 3 of 3


My earlier response requires some clarification:

There is an obvious sine solution which is y = (M/(-w*w+g))*sin(wt).
But this only works if you form the ODE by differentiating twice, in which case
y" = (-M*w*w/(-w*w+g))*sin(wt) and hence y"+gy = Msin(wt).
(This only works if w*w is not equal to g, so doesn't allow for my previous solution which assumed w = g = M =1.)

However, if you start with the above y" and integrate it twice to get y, which is what Simulink does if you feed that as an input into 2 cascaded integrator blocks, then due to the constant of integration you do not get that y"+gy = Msin(wt).
You do however get y"+gy = Msin(wt) if you set the initial condition of the first integrator (the one going from y" to y') to be M/(w*w+g).
This removed the offset from y' that is introduced by the constant of integration.

Phil.

"Phil Goddard" <philgoddardNOSPAM@telus.net> wrote in message <gjeet9$479$1@fred.mathworks.com>...
>
> You need to revise the fundamentals of integration:
>
> > I also noticed that if one used a sine block (Msinwt) as input to an integrator, he gets the output of the integrator as M+Mcos(wt). Why not just Mcos(wt)?
>
> The integral of a sine wave is the negative of a cosine plus a constant, where the value of the constant is the value of the cosine at t = t0.
> So for u = sin(t), integrated from t0=0, the integral is 1-cos(t).
> Not surprisingly this is what Simulink gives.
>
> > For example, my 2n order ode is:
> >
> > y'' + gy = Msin(wt).
> >
> > g is a constant.
> >
> > The solution to this ode shd be a sine function.
>
> I can't think of a case where the solution is a pure sine wave.
> For the (easy) case of g = M = w = 1 the solution is y = -0.5 * t * cos(t).
> Again, not surprisingly this is what Simulink gives.
> For the more generic case y will be something like a*sin(wt) + b*cos(wt) where a and b are functions of g, M and w.
>
> Phil.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
simulink Emeka Obe 30 Dec, 2008 14:05:06
2nd order ode Emeka Obe 30 Dec, 2008 14:05:06
rssFeed for this Thread

Contact us at files@mathworks.com