Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Solving coupled ODEs, with function constraint

2 views
Skip to first unread message

Anup

unread,
Feb 12, 2013, 11:50:25 AM2/12/13
to
Hi,

I am having some trouble when trying to solve a coupled ODE with constraints.

The ODE solver function (copied below) works when no constraints are used.

I need to limit (constrain) the force function Fpto = bpto*y(2) + cpto*y(1) within a certain range. The force, to be constrained, can be seen in the last statement of the copied code below.

Can someone please throw some light on how this can be done? Thank you very much for your time!

Kind regards, Anup

function [ypms] = WECmotion(t,y,A,B,C,D,Fe,tb_new)

m = 1.033553890374489e-07; c = 0; k = 2.702788060000000e+07; bpto=10^7; cpto=-10^7;

Fex_t = interp1(tb_new,Fe,t);

ypms(1,1) = y(2); ypms(3:10,1)=A*y(3:10)+B*y(1); ypms(2,1) = [Fex_t - c*y(2) - k*y(1) - C*ypms(3:10) - D*y(1) - bpto*y(2) - cpto*y(1)]*m;

Anup

unread,
Feb 19, 2013, 6:20:06 AM2/19/13
to
Hi,

I have now successfully implemented the constraint in the code.

All that needed was another variable defined

Fpto = bpto*y(2) + cpto*y(1)

and an if/else statement to put the hard limit on Fpto.

The last line in the code now becomes,

ypms(1,1) = y(2); ypms(3:10,1)=A*y(3:10)+B*y(1); ypms(2,1) = [Fex_t - c*y(2) - k*y(1) - C*ypms(3:10) - D*y(1) - Fpto]*m;

Regards,
Anup

"Anup" wrote in message <kfdrsh$sg$1...@newscl01ah.mathworks.com>...
0 new messages