Path: news.mathworks.com!not-for-mail
From: "Phil Goddard" <philgoddardNOSPAM@telus.net>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Solving 2nd order ode in Simulink
Date: Wed, 31 Dec 2008 08:19:04 +0000 (UTC)
Organization: Goddard Consulting
Lines: 38
Message-ID: <gjf9to$m55$1@fred.mathworks.com>
References: <gjdr97$b06$1@fred.mathworks.com> <gjeet9$479$1@fred.mathworks.com>
Reply-To: "Phil Goddard" <philgoddardNOSPAM@telus.net>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1230711544 22693 172.30.248.38 (31 Dec 2008 08:19:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 31 Dec 2008 08:19:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 26433
Xref: news.mathworks.com comp.soft-sys.matlab:509306



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.